QML: Get the parent of a QObject

QML represents a separate ownership tree ( QObject) from the visual tree (QtQuick scene graph).

  • parent returns the visual parent.
  • children returns visual child elements.
  • datareturns child elements QObject.

But how do I access the parent element QObject?

FYI, I intend to dynamically create and destroy nested layouts containing a custom type, so I need to manage the tree QObject. Just using the visual tree will cause the “wrong” objects to disappear after the repair and then be deleted.

+4
source share
1

, , , ++. QObject, QML, data . ( , .)

Qt Quick Concepts:

, , QObject . , , data, Item, Item:: children . ( Qt Quick , , .)

+1

All Articles