NOTIFY on grouped properties
-
I am trying to use 'grouped properties' and want to be able to use onXChanged for my grouped properties. But I get this error
QQmlExpression: Expression qrc:/main.qml:13:5 depends on non-NOTIFYable properties: Appearance::colors
referring to
color: { return Appearance.colors.backgroundColor }
And main.qml is
Window { width: 640 height: 480 visible: true title: qsTr("Test for Appearance") color: { return Appearance.colors.backgroundColor; } } ... My Appearance class (which is a singleton): class Appearance : public QObject, public Singleton<Appearance> { friend class TeliumLib::TL_Singleton<Appearance>; Q_OBJECT Q_PROPERTY(Colors* colors READ colorsGroup NOTIFY sig_colorsChange) Q_PROPERTY(Fonts* fonts READ fontsGroup) Q_PROPERTY(Icons* icons READ iconsGroup) public: TLQ_A_Colors* colorsGroup(); TLQ_A_Fonts* fontsGroup(); TLQ_A_Icons* iconsGroup(); private: Colors* m_colorsPtr; Fonts* m_fontsPtr; Icons* m_iconsPtr; };
My Colors class is:
class Colors : public QObject { Q_OBJECT Q_PROPERTY(QString background READ background NOTIFY sig_backgroundChanged)
-
@raven-worx My intention was to allow this property to change. But I found the issue...if I add notify to either APpearance or Color QML files, then it complains. But if I add NOTIFY to BOTH Appearance and COlors then it no longer complains. I'm not sure what signal it will receive...but I can figure that out.
@ocgltd
EVERY property you use in a statement must either be CONSTANT or have a NOTIFY signal.
depending on which property gets changed, this notifier signal causes a reevaluation of the property binding. -
I am trying to use 'grouped properties' and want to be able to use onXChanged for my grouped properties. But I get this error
QQmlExpression: Expression qrc:/main.qml:13:5 depends on non-NOTIFYable properties: Appearance::colors
referring to
color: { return Appearance.colors.backgroundColor }
And main.qml is
Window { width: 640 height: 480 visible: true title: qsTr("Test for Appearance") color: { return Appearance.colors.backgroundColor; } } ... My Appearance class (which is a singleton): class Appearance : public QObject, public Singleton<Appearance> { friend class TeliumLib::TL_Singleton<Appearance>; Q_OBJECT Q_PROPERTY(Colors* colors READ colorsGroup NOTIFY sig_colorsChange) Q_PROPERTY(Fonts* fonts READ fontsGroup) Q_PROPERTY(Icons* icons READ iconsGroup) public: TLQ_A_Colors* colorsGroup(); TLQ_A_Fonts* fontsGroup(); TLQ_A_Icons* iconsGroup(); private: Colors* m_colorsPtr; Fonts* m_fontsPtr; Icons* m_iconsPtr; };
My Colors class is:
class Colors : public QObject { Q_OBJECT Q_PROPERTY(QString background READ background NOTIFY sig_backgroundChanged)
@ocgltd
thisQ_PROPERTY(Colors* colors READ colorsGroup)
should be
Q_PROPERTY(Colors* colors READ colorsGroup CONSTANT)
and you should also treat it like this. Means the Colors instance must not change for the QObjects lifetime.
if thats not your intention then this property also needs a NOTIFY signal. -
@ocgltd
thisQ_PROPERTY(Colors* colors READ colorsGroup)
should be
Q_PROPERTY(Colors* colors READ colorsGroup CONSTANT)
and you should also treat it like this. Means the Colors instance must not change for the QObjects lifetime.
if thats not your intention then this property also needs a NOTIFY signal.@raven-worx My intention was to allow this property to change. But I found the issue...if I add notify to either APpearance or Color QML files, then it complains. But if I add NOTIFY to BOTH Appearance and COlors then it no longer complains. I'm not sure what signal it will receive...but I can figure that out.
-
@raven-worx My intention was to allow this property to change. But I found the issue...if I add notify to either APpearance or Color QML files, then it complains. But if I add NOTIFY to BOTH Appearance and COlors then it no longer complains. I'm not sure what signal it will receive...but I can figure that out.
@ocgltd
EVERY property you use in a statement must either be CONSTANT or have a NOTIFY signal.
depending on which property gets changed, this notifier signal causes a reevaluation of the property binding.