Adding more attached properties to Accessible - cannot assign to non-existent property
-
Hi,
I've been trying to add an additional extended property to Accessible in an effort to see if I can get labelledBy etc. to work but am having an issue accessing the new attached property (cannot assign to non-existent property "labelledBy").
I have copied the implementation of description in
qtdeclarative/src/quick/items/qquickaccessibleattached_p.h
and changed to property name tolabelledBy
, but it is otherwise exactly the same ie. a simpleQString
property. To test this, I have setAccessible.labelledBy: "test"
in a KDE application (tokodon) built against my ownlibQt5Quick.so
which has been confirmed withldd
andcat /proc/$(pidof tokodon)/maps | grep Quick
.A patch of the changes is here:
diff --git a/src/quick/items/qquickaccessibleattached_p.h b/src/quick/items/qquickaccessibleattached_p.h index c24bce7bda..24110f10d4 100644 --- a/src/quick/items/qquickaccessibleattached_p.h +++ b/src/quick/items/qquickaccessibleattached_p.h @@ -88,6 +88,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAccessibleAttached : public QObject Q_PROPERTY(QAccessible::Role role READ role WRITE setRole NOTIFY roleChanged FINAL) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged FINAL) Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged FINAL) + Q_PROPERTY(QString labelledBy READ labelledBy WRITE setLabelledBy NOTIFY labelledByChanged FINAL) Q_PROPERTY(bool ignored READ ignored WRITE setIgnored NOTIFY ignoredChanged FINAL) QML_NAMED_ELEMENT(Accessible) @@ -146,6 +147,15 @@ public: } } + QString labelledBy() const { return m_labelledBy; } + void setLabelledBy(const QString &labelledBy) + { + if (m_labelledBy != labelledBy) { + m_labelledBy = labelledBy; + Q_EMIT(labelledByChanged()); + } + } + // Factory function static QQuickAccessibleAttached *qmlAttachedProperties(QObject *obj); @@ -205,6 +215,7 @@ Q_SIGNALS: void roleChanged(); void nameChanged(); void descriptionChanged(); + void labelledByChanged(); void ignoredChanged(); void pressAction(); void toggleAction(); @@ -226,6 +237,7 @@ private: QString m_name; bool m_nameExplicitlySet = false; QString m_description; + QString m_labelledBy; static QMetaMethod sigPress; static QMetaMethod sigToggle;
I get the feeling I'm likely missing something obvious as everything appears to be as it should, my only though is maybe moc is doing something funny so I have cleaned and rebuilt and still the same result so I'm really not sure.
Any help would be much appreciated.
Many thanks,
Brent