Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.3.1, 5.5.0 Beta
-
None
-
all
Description
If revisioned property of a class is set via another property, the import version information is somehow ignored.
For example, I have these two properties in my abstract base class:
class MyAbstractBaseClass : public QObject { Q_OBJECT // "originalProp" was in the initially released version Q_PROPERTY(bool originalProp READ originalProp WRITE setOriginalProp NOTIFY originalPropChanged) // "newProp" was introduced in version 1.1, and therefore has revision 1 Q_PROPERTY(bool newProp READ newProp WRITE setNewProp NOTIFY newPropChanged REVISION 1) //...
I register revisions like this:
qmlRegisterUncreatableType<MyAbstractBaseClass>("MyTypes", 1, 0, "MyAbstractBaseClass", QLatin1String("Trying to create uncreatable: MyAbstractBaseClass.")); qmlRegisterUncreatableType<MyAbstractBaseClass, 1>("MyTypes", 1, 1, "MyAbstractBaseClass", QLatin1String("Trying to create uncreatable: MyAbstractBaseClass."));
The abstract class is subclassed by "MySubClass", which is then used as a property in another class:
class MyItem : public QObject { Q_OBJECT Q_PROPERTY(MySubClass* first READ first WRITE setFirst NOTIFY firstChanged) Q_PROPERTY(MySubClass* second READ second WRITE setSecond NOTIFY secondChanged) //...
Now, in QML, I try to set the properties as follows, but trying to set the "newProp" in the context of the MyItem fails:
Window { visible: true width: 360 height: 360 MySubClass { id: mySubClass originalProp: false // If MySubClass item is declared like this, it can use revision 1 property just fine newProp: false } MyItem { id: myItem // This works as expected first: mySubClass // Using the original revision 0 property from default object like this works just fine: second.originalProp: false // Using the revision 1 property from default object like this gives an error: // --> qrc:///main.qml:28 ".newProp" is not available due to component versioning. second.newProp: false } //...
As the code comments above describe, trying to do "second.newProp: false" complains about "newProp" not being available due to component versioning, even though it was successfully used in MySubClass scope above.
Also, doing this later in onClicked scope works fine, so the above error definitely feels like a bug:
console.log("myItem.second.newProp: ", myItem.second.newProp)
Attached an example application to demonstrate the issue.
Am I registering the QML types somehow incorrectly, or is there a bug in Qt?
Attachments
Issue Links
- relates to
-
QTBUG-65463 ApplicationWindow.window attached property not available due to component versioning
- Closed
- resulted in
-
QTBUG-50990 QML Revisions in qmlRegisterUncreatableType not honored
- Reported
-
QTBUG-48966 Positioner "padding" properties are not accessible in attached case
- Closed