QML warning: depends on non-NOTIFYable properties
Below code:
Item
{
visible: {
if (type) return true;
else return false;
}
}
If "type" property is not notifiable, you will see this message:
QmlExpression: Expression qrc:/qml/default/element/Button.qml:172:26 depends on non-NOTIFYable properties:
Button_QMLTYPE_12::type
Usually this happens when "type" is user-defined property and it doesn't have NOTIFY in Q_PROPERTY.
The solution is obvious:
Item
{
visible: {
if (type) return true;
else return false;
}
}
If "type" property is not notifiable, you will see this message:
QmlExpression: Expression qrc:/qml/default/element/Button.qml:172:26 depends on non-NOTIFYable properties:
Button_QMLTYPE_12::type
Usually this happens when "type" is user-defined property and it doesn't have NOTIFY in Q_PROPERTY.
The solution is obvious:
- Add NOTIFY to the property "type"
- Add CONSTANT in the last of Q_PROPERTY
For #1, it's
Q_PROPERTY(int type READ getType WRITE setType NOTIFY typeChanged)
For #2, it's
Q_PROPERTY(int type READ getType WRITE setType CONSTANT)
留言
張貼留言