Bindings not updating when property notify signal is emitted
-
I have a situation where a property binding is not updating when the appropriate C++ property notify signal is changed, despite a
Connections
object responding to the signal properly. For example:TextEdit { id: descriptionEdit // `enabled` never changes enabled: eventModel.numDescriptionWritable > 0 // But this one works. What gives? Connections { onNumDescriptionWritableChanged { print('numDescriptionWritableChanged():', eventModel.numDescriptionWritable) } } }
What sort of conditions would make the possible?
-
hi @patrickkidd
have you tried with parentheses ?
enabled: (eventModel.numDescriptionWritable > 0 )
and do you assign anywhere a bool to enabled, using
=
? If yes, than that breaks all previous bindings. -
@J.Hilk said in Bindings not updating when property notify signal is emitted:
hi @patrickkidd
have you tried with parentheses ?
enabled: (eventModel.numDescriptionWritable > 0 )
and do you assign anywhere a bool to enabled, using
=
? If yes, than that breaks all previous bindings.Nope, haven't assigned bool anywhere else. Parenthesis doesn't seem to work.
-
@patrickkidd
particular ...what does the console log print here ?
TextEdit { id: descriptionEdit // `enabled` never changes enabled: eventModel.numDescriptionWritable > 0 Component.onCompleted: console.log("descriptionEdit completed", eventModel.numDescriptionWritable, enabled)
-
@J.Hilk said in Bindings not updating when property notify signal is emitted:
@patrickkidd
particular ...what does the console log print here ?
TextEdit { id: descriptionEdit // `enabled` never changes enabled: eventModel.numDescriptionWritable > 0 Component.onCompleted: console.log("descriptionEdit completed", eventModel.numDescriptionWritable, enabled)
It prints 0 and false, which are the correct values before the model is initialized and before the integer becomes nonzero. Though I think the Connections object is already accomplishing the purpose of that print statement. Therefore, setting ‘enabled’ explicitly from the connections object is a workout that works, though I’d like to fix the problem itself.