Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
TreeView in QML?
Deqing last edited by
I'd like to create a TreeView by QML: folders on the left side, files on the other side. Can drag file to folders.
andre last edited by
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.
SteveKing last edited by
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.