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. TreeView in QML?

TreeView in QML?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 3 Posters 5.4k 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.
  • D Offline
    D Offline
    Deqing
    wrote on last edited by
    #1

    Hi All,

    I'd like to create a TreeView by QML: folders on the left side, files on the other side. Can drag file to folders.

    Any suggestions?

    Thanks,
    Deqing

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Good luck!

      Basically, I think you will have to make a list of delegates, that recursively also contain a list of the same delegate. That is not going to be trivial to get right, I think.

      With QML slated to move really into the desktop space, I hope the model/view implementation in it will be extended again to also support tables and trees. The current implementation is fine for mobile devices, but it is not enough for the desktop, I think.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SteveKing
        wrote on last edited by
        #3

        Hi,

        We have implemented something similar to this (without the drag + drop). Our solution is to store the folder structure as a C++ list model, with items being inserted/deleted when the view opens or closes a folder. Using roles for the items allows the QML to know whether the item has children and if it's open.

        This breaks the model/view structure in that the underlying model knows which folders are open in the view, but it means the QML is nice and simple.

        Regards,
        Steve

        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