TreeView in QML?

  • 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?


  • 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.

  • 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.


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.