what is the best way to Filter different types of files in QTreewidget/QListWidget?
-
Hi,
Are you thinking about something like this ?
-
@SGaist thank you ,but i just use QTreeWidget/QListWidget, donot use QFileSystemModel.
and how about QSortFilterProxyModel, can i also work for my problem? -
and the dataItem type is my custom, which is store in QTreeWidgetItem/QListWidgetItem.
i also want to show Only the Dirs...
or all the dirs with specified type of file.
thank you -
it seems that there is no good way to filter...
i think i have to re-setup the QTreeWidget/QListWidget everytime i select a different type of filterType...because i found there is not way to use QFileSystemMode or QSortFilterModel while i use QTreeWidget/QListWidget
-
No there's not indeed, however your have QTreeView that might your needs
-
@SGaist thank you ,i traverse all the items and setHidden true or false by myself...
-
How many files/folders are you going to handle that way ?
-
@SGaist maybe hundreds or even thousands...is there better way?
-
Then why don't you use a QFileSystemModel ?
-
@SGaist i don't know how to use it...because i use QTreeWidget but not QTreeView...
i think i even can't find a setModel() api in QTreeWidget/QListWidget... -
You have to use QTreeView/QListView classes when using a model like that.
-
@SGaist ok...but i think i can't use QTreeView...
-
Why can't you ?
-
@SGaist already write many code...
-
Refactoring might be hard but it's generally a good thing to have a clean code base