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. QML FolderListModel + TreeView !== tree view
Forum Updated to NodeBB v4.3 + New Features

QML FolderListModel + TreeView !== tree view

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 2.1k 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.
  • H Offline
    H Offline
    hlb-schmidt
    wrote on 13 Sept 2018, 08:29 last edited by
    #1

    not sure if bug or me being stupid...

    when i go to https://doc.qt.io/qt-5/qml-qtquick-controls-treeview.html and look at the example screenshot
    0_1536827265554_treeview.png
    i see a tree view, with expanding folders. cool, exactly what i want!

    then i try to use that with https://doc.qt.io/qt-5/qml-qt-labs-folderlistmodel-folderlistmodel.htm

    test.qml:

    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
    0_1536826964986_test-qmlscene.png

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

    qml test.qml
    0_1536826992762_test-qml.png

    • why is here no entries at all?

    am i doing something wrong?
    bug(s)?

    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)
    
    1 Reply Last reply
    2
    • G Offline
      G Offline
      GPBeta
      wrote on 13 Sept 2018, 09:09 last edited by
      #2

      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

      \BAKA BAKA/

      1 Reply Last reply
      1
      • H Offline
        H Offline
        hlb-schmidt
        wrote on 13 Sept 2018, 10:53 last edited by
        #3

        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 ;)

        1 Reply Last reply
        0

        1/3

        13 Sept 2018, 08:29

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved