Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.12, 6.6.1
-
None
Description
Using Qt 5.15.12 or Qt 6.6.1, QML properties trigger their "onChanged" signal during initialisation inconsistently depending on their types. With the given example:
import QtQml 2.15 import QtQuick 2.15 Item { property bool a0: false property bool a1: true onA0Changed: console.log("a0Changed", a0); onA1Changed: console.log("a1Changed", a1); property vector3d b0: Qt.vector3d(0, 0, 0) property vector3d b1: Qt.vector3d(0, 0, 1) onB0Changed: console.log("b0Changed", b0); onB1Changed: console.log("b1Changed", b1); }
Output in Qt5:
qml: b1Changed QVector3D(0, 0, 1)
Ok, I guess b1 signal is triggered and not b0 because default value of b0 is QVector3D(0, 0, 0), so for b1 the comparison failed, the value changes from the default hence the signal is triggered. But if this is how it works, why is the boolean property a1 not triggering its onChanged signal ?
Output in Qt6:
qml: b0Changed QVector3D(0, 0, 0) qml: b1Changed QVector3D(0, 0, 1)
Here even b0 signal is triggered, but again the boolean type does not trigger its onChanged signal. Why ? Is this because one is a value type and the other is a reference type ? In the case of vector3d the comparison is not about value but about different object ? If so why different values for the boolean type does not trigger too ?
Either the signal should not be triggered at all during property initialisation, or it should be triggered every time the value / object changed from the default one but I don't see anything on the documentation about this. Maybe this behaviour is not the expected one ?
This issue is not about comparing Qt 5 with Qt 6, but I show their outputs to emphasis what I think is inconsistency in both versions.