Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    TreeView in QML?

    QML and Qt Quick
    3
    3
    5206
    Loading More Posts
    • 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
      Deqing last edited by

      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 Reply Quote 0
      • A
        andre last edited by

        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 Reply Quote 0
        • S
          SteveKing last edited by

          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 Reply Quote 0
          • First post
            Last post