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 recursive instantiation.
Qt 6.11 is out! See what's new in the release blog

QML recursive instantiation.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 1.9k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    Jim Gir
    wrote on last edited by Jim Gir
    #1

    Hi,
    REcursive instantiation is not allowed in QML as I see. https://codereview.qt-project.org/c/qt/qtdeclarative/+/30237
    But how to accomplish this ? :

    # MyComp.qml
    Item {
        Repeater {
           model : [somedata]
           delegate: MyComp{} 
       }
    }
    

    There is no risk of infinite recursion since instantiation is controlled by the model.

    I would need it to build something like a tree.

    Thanks for help
    Jimmy

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      If this were allowed, just one item in your model would cause infinite recursion.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3

        Long answer:
        Build a model in C++ around a tree structure. Use the TreeView object to display this tree. Your MyComp.qml can be used as a delegate.

        C++ is a perfectly valid school of magic.

        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