Important: Please read the Qt Code of Conduct -

QML FolderListModel + TreeView !== tree view

  • not sure if bug or me being stupid...

    when i go to and look at the example screenshot
    i see a tree view, with expanding folders. cool, exactly what i want!

    then i try to use that with


    import QtQuick.Controls 1.4
    import Qt.labs.folderlistmodel 2.11
    TreeView {
    	width: 300
    	height: 300
    	model: dirModel
    	TableViewColumn {
    		role: "fileName"
    	FolderListModel {
    		id: dirModel
    		folder: "/etc"

    but instead the suggested view from the example screenshot, i get:

    qmlscene test.qml

    • where are those folder triangle icons from the screenshot?! (eg. X11 is a dir)
    • nothing happens when i click a folder!?

    qml test.qml

    • why is here no entries at all?

    am i doing something wrong?

    tested with qt5-declarative 5.11.1 on linux.

    ps. FWIW, this is in virtualbox, and i do get following uncritical? errors on launch:

    libGL error: pci id for fd 12: 80ee:beef, driver (null)
    libGL error: No driver found
    libGL error: failed to load driver: (null)

  • Hi, please be aware that so-called FolderListModel is typically a ListModel not TreeModel, it's a linear model and be suitable to make use with ListView.

    The fileSystemModel object mention in the example is not an instance of FolderListModel as you assume.

    As far as I know, there's no pure QML way to get full functionality of TreeView, you have to make your own model as the document of TreeView mentioned:

    Data for each row in the TreeView is provided by the model. TreeView accepts models derived from the QAbstractItemModel class.

    HOWTO: Simple Tree Model

  • ah! so was my mistake to assume that "Folder" in name suggested a tree. and i should have seen the List in FolderListModel :/

    thank you very much for your explanation!

    ps. so what i need is a FolderTreeModel, and as i dont have fun in cross-compiling nor c++, ill try again when such qml type exists in qt ;)

Log in to reply