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. Tree model in QML without C++
Forum Update on Monday, May 27th 2025

Tree model in QML without C++

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 2.7k 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.
  • K Offline
    K Offline
    Krasi
    wrote on last edited by A Former User
    #1

    Hi

    can you create a model that can be used for treeview using qml only?

    all articles I found implement the model in c++

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Im not QML user but the only thing about pure QML models i could find was this
      http://doc.qt.io/qt-5/qtquick-xmllistmodel-qmlmodule.html
      So not sure you can defien new models in QML alone.
      Could be cool though :)

      K 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        Im not QML user but the only thing about pure QML models i could find was this
        http://doc.qt.io/qt-5/qtquick-xmllistmodel-qmlmodule.html
        So not sure you can defien new models in QML alone.
        Could be cool though :)

        K Offline
        K Offline
        Krasi
        wrote on last edited by
        #3

        @mrjj thanks but this is for list model. I am interested in treemodel with parent-child relations

        mrjjM 1 Reply Last reply
        0
        • K Krasi

          @mrjj thanks but this is for list model. I am interested in treemodel with parent-child relations

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Krasi
          Hi
          I think you need to use c++ for that.
          Sadly.

          1 Reply Last reply
          0
          • O Offline
            O Offline
            Oliver Heggelbacher
            wrote on last edited by
            #5

            I was stuck at the same point, "why are the example only static read-only c++ models"?

            I found two helpful pure QML examples for custom made tree views that use QML ListModel and Javascript arrays, e.g:

            Youtube - TreeView component in pure Qt Quick
            https://gist.github.com/pcdummy/c03845aa9449168b7d24c491ad913fce

            QMLRearrangeableTreeView from Eric Gregory which showcases drag&drop. I extended it to make it editable, and save/load the structure via a JSON string:
            QMLRearrangeableTreeView for edit&save

            Hope this can help.

            1 Reply Last reply
            2

            • Login

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