Reputation: 2045
I have a canvas that contains a few MouseAreas that can be dragged. The canvas draws some decoration between these items that cannot be expressed as native QML elements.
How can I initiate a redraw of the canvas when an Item changes size or position? I know that I need to call canvas.requestPaint(), but on which event? The only solution I found so far was calling requestPaint() within a timer, but I want to avoid that due to performance reasons.
Upvotes: 4
Views: 7469
Reputation: 25552
According to the QML documentation, each property of a QML
component has an implicit signal associated with a change of value in the property:
Signal handlers for property change signal take the syntax form
on<Property>Changed
where<Property>
is the name of the property, with the first letter capitalized. For example, although the TextInput type documentation does not document a textChanged signal, this signal is implicitly available through the fact that TextInput has a text property and so it is possible to write an onTextChanged signal handler to be called whenever this property changes
Upvotes: 6