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. Is there a way to create a model for TreeView in pure Qml (without using C++)
Forum Updated to NodeBB v4.3 + New Features

Is there a way to create a model for TreeView in pure Qml (without using C++)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 316 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.
  • Serhan KarsS Offline
    Serhan KarsS Offline
    Serhan Kars
    wrote on last edited by
    #1

    I managed to list two nodes in my TreeView using ListModel and ListElement. But I could not try to display a hierarchy of items in my tree view. Is there a way of doing this? Maybe just passing a JS object. An example would be great!

    ListModel {
        ListElement {
            name: "Root"
            rows: [
                ListElement {
                    name: "Child 1"
                },
                ListElement {
                    name: "Child 2"
                }
            ]
        }
        ListElement {
            name: "Root 2"
        }
    }
    
    1 Reply Last reply
    0
    • Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on last edited by
      #2

      Sure, that's possible. There is even an example in its documentation!

      Software Engineer
      The Qt Company, Oslo

      1 Reply Last reply
      0
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #3

        No it isn't possible, as confirmed by the link given by Axel.
        I've heard it's planned but don't plan on it too soon.

        1 Reply Last reply
        0
        • Serhan KarsS Offline
          Serhan KarsS Offline
          Serhan Kars
          wrote on last edited by
          #4

          Dear @Axel-Spoerl Thanks for the answer. Which part of documentation are you referring to? The comment section?

              // The model needs to be a QAbstractItemModel
              // model: yourTreeModel
          
          1 Reply Last reply
          0
          • Serhan KarsS Serhan Kars has marked this topic as solved on

          • Login

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