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 Updated to NodeBB v4.3 + New Features

Tree model in QML without C++

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 2.7k Views 2 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.
  • K Offline
    K Offline
    Krasi
    wrote on 13 Dec 2016, 12:40 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 13 Dec 2016, 15:24 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 15 Dec 2016, 12:17
      0
      • M mrjj
        13 Dec 2016, 15:24

        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 15 Dec 2016, 12:17 last edited by
        #3

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

        M 1 Reply Last reply 15 Dec 2016, 12:20
        0
        • K Krasi
          15 Dec 2016, 12:17

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

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 15 Dec 2016, 12:20 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 13 Jun 2018, 14:57 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