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. Display a QFileSystemModel in two Views: Tree View and a TableView/ListView of selected items
Forum Updated to NodeBB v4.3 + New Features

Display a QFileSystemModel in two Views: Tree View and a TableView/ListView of selected items

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 1.1k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    Hi,

    I have a TreeView of a QFileSystemModel where I can select files for later use. I store the model indices of these files, and would like to show the selected files in a TableView. How could this be achieved?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You could use a custom QSortFilterProxyModel to filter out the elements not matching your selection.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maxwell31
        wrote on last edited by
        #3

        Thanks. I thought about doing this. But I might not understand the QFileSystemModel right yet. If I do

        bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override {
            if(source_parent.data(FileSystemModel::IsCheckedRole)==true)
                return true;
            else
                return false;
        }
        

        And display the view as a TreeView nothing is shown, because the root node has IsCheckedRole false. The way I implemented IsCheckedRole is that my model simply contains a list of QModelIndex which stores the items for which IsCheckedRole is true (like this I could avoid walking through the tree). So the problem maybe is, that I have a hierarchical model but would only want a list in my second view.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Why not pass it the selected model indexes from the selection model of your view and filter out everything that's not in that list ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

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