When a QLabel was displaying rich text, the raw html was being returned as
accessible name. Now the plain text is returned.
Task-number: QTBUG-27302
Change-Id: I169d5eff527a0aef810af11d7712a362148974a5
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
#include <qlineedit.h>
#include <qstyle.h>
#include <qstyleoption.h>
+#include <qtextdocument.h>
#include <QtCore/qvarlengtharray.h>
#ifdef Q_OS_MAC
str = widget()->accessibleName();
if (str.isEmpty()) {
if (qobject_cast<QLabel*>(object())) {
- str = qobject_cast<QLabel*>(object())->text();
+ QLabel *label = qobject_cast<QLabel*>(object());
+ str = label->text();
+ if (label->textFormat() == Qt::RichText
+ || (label->textFormat() == Qt::AutoText && Qt::mightBeRichText(str))) {
+ QTextDocument doc;
+ doc.setHtml(str);
+ str = doc.toPlainText();
+ }
#ifndef QT_NO_LCDNUMBER
} else if (qobject_cast<QLCDNumber*>(object())) {
QLCDNumber *l = qobject_cast<QLCDNumber*>(object());