Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.11.0
-
None
Description
I exported a data structure to QML by creating a QObject with properties and then registering it using qmlRegisterType<..>(..). Then I tried to set some properties using the parent object:
MyPane { // Custom Pane, property is set where the component is used. property int entityId MyEntity { // Exported QObject // This does not work! I get an undef is assigned to int warning, but // that's it. entityId: parent.entityId } }
I solved the issue by giving the parent an id and then refer through this in the child QObject. Now of course this is not a defect in QML but very confusing for QML devs (and I wasted some time figuring this out). I propose two things:
- At least give a warning if the parent property is accessed from a non- QQuickItem or do not compile at all.
- More convenient: Make parent work somehow all the time in QML. I do not see a use case where the parent property should not refer to the parent.