Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML: Get QObject parent
QtWS25 Last Chance

QML: Get QObject parent

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cmannett85
    wrote on last edited by
    #1

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

    • parent returns the visual parent.
    • children returns the visual children.
    • data returns the QObject children.
    • But how do I access the QObject parent?

    FYI, I intend on dynamically creating and destroying nested layouts containing a custom type, so I need to manage the QObject tree - just using the visual tree will result in the 'wrong' objects disappearing after reparenting and later deleting.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Very easy to do on the C++ side, just pass your item there and it's easily castable to QObject.

      Or try with parent.data, although your post would suggest it can return false data.

      (Z(:^

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved