Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
5.0.1
-
None
-
Windows 7 32-bit, MSVC2010
Description
Setting a property value on a Text component with a PropertyAction gets the old value. Let me explain using the QML code eblow:
Initially, newText is "".
From elsewhere in QML set label.newText = "string1".
This causes onNewTextChanged to fire. Good.
Console displays "Replacing text string1". Good.
The animation setNewTextAnimation starts.
The ScriptAction causes the console to log the value of "label.newText":
> "Script: string1" Good.
The PropertyAction writes what it thinks is the value of "label.newText"
- You would expect that the label.text property is written to and causing the onTextChanged slot to fire. But it doesn't, because the PropertyAction reads "" from the label.newText property and setting it makes no change.
Lets check with a further write to newText:
> label.newText = "string2"
This causes onNewTextChanged to fire. Good.
Console displays "Replacing text string2". Good.
The animation setNewTextAnimation starts.
The ScriptAction causes the console to log the value of "label.newText":
> "Script: string2". Good.
The PropertyAction writes what it thinks is the value of "label.newText"
- Now the onTextchanged slot fires because the new value being read (old) is "string1" and this is different to "".
> "TextChanged string1" * This is the OLD value!!
In summary, the ScriptAction is able to get the true correct value of the property, but the PropertyAction seems to read its PREVIOUS value.
Text { id: label property string newText: "" onNewTextChanged: { console.log("Replacing text", newText); setNewTextAnimation.start() } onTextChanged: console.log("TextChanged", text) SequentialAnimation { id: setNewTextAnimation ScriptAction { script: { console.log("Script:", label.newText) } } PropertyAction { target: label; property: "text"; value: label.newText } } }
Attachments
Issue Links
- duplicates
-
QTBUG-13268 Bindings in transitions not evaluated (from property in animation)
- Open