Call QAccessible::updateAccessibility when setText is called on QLabel
authorJosé Millán Soto <fid@gpul.org>
Thu, 14 Jul 2011 12:25:57 +0000 (14:25 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 26 Aug 2011 20:42:10 +0000 (22:42 +0200)
The method is called when the text of a label is changed and setAccessibleName has
not been called on the label, as the text of the label acts as the accessible name
of the label.

Merge-request: 1301
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
(cherry picked from commit a1f2b68e97477440cf508e6d497eb5f5d9971971)

Change-Id: Ic10f75e72ac3faa84777c444177b287b720a1dc2
Reviewed-on: http://codereview.qt.nokia.com/3040
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
src/gui/widgets/qlabel.cpp

index 7a94f42..ab88f38 100644 (file)
 #include "private/qstylesheetstyle_p.h"
 #include <qmath.h>
 
+#ifndef QT_NO_ACCESSIBILITY
+#include <qaccessible.h>
+#endif
+
 QT_BEGIN_NAMESPACE
 
 /*!
@@ -377,6 +381,11 @@ void QLabel::setText(const QString &text)
 #endif
 
     d->updateLabel();
+
+#ifndef QT_NO_ACCESSIBILITY
+    if (accessibleName().isEmpty())
+        QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged);
+#endif
 }
 
 QString QLabel::text() const