Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.5.6
-
None
-
-
8bfd582da (dev), eb460e4ee (6.8), ef97a93f3 (6.7), 8b1467db9 (tqtc/lts-6.5)
Description
Qt.binding fails with QtQObject inside createObject with output 'Could not set initial property obj'
consider the following script
import QtQuick Item { property Component object: QtObject { property QtObject obj } Component.onCompleted: { const item = object.createObject(this, { obj: null }) const item2 = object.createObject(this, { obj: Qt.binding(() => item) }) print(item, item.obj, item2, item2.obj) } }
Output -
prince@prince-virtual-machine:~/Desktop/tests $ /home/prince/Qt/6.2.4/gcc_64/bin/qml binding.qml qml: QObject_QML_1(0x1905f40) null QObject_QML_1(0x1911ad0) QObject_QML_1(0x1905f40) prince@prince-virtual-machine:~/Desktop/tests $ /home/prince/Qt/6.6.3/gcc_64/bin/qml binding.qml file:///home/prince/Desktop/tests/binding.qml: Could not set initial property obj qml: QObject_QML_1(0x57d68badfd90) null QObject_QML_1(0x57d68bae2c30) null
As you can see above Qt 6.6.3 fails while Qt6.2.4 gives the correct output, Same behaviour can be observed with a Q_GADGET
Edit: Note that changing obj property type to 'var', fixes the problem
Attachments
For Gerrit Dashboard: QTBUG-125095 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
573591,4 | QQmlProperty: Handle binding assignment earlier | dev | qt/qtdeclarative | Status: MERGED | +2 | +1 |
573855,2 | QQmlProperty: Handle binding assignment earlier | 6.8 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
573973,3 | QQmlProperty: Handle binding assignment earlier | 6.7 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
574135,3 | QQmlProperty: Handle binding assignment earlier | tqtc/lts-6.5 | qt/tqtc-qtdeclarative | Status: MERGED | +2 | 0 |