Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. what is the best way to Filter different types of files in QTreewidget/QListWidget?
Forum Updated to NodeBB v4.3 + New Features

what is the best way to Filter different types of files in QTreewidget/QListWidget?

Scheduled Pinned Locked Moved General and Desktop
16 Posts 2 Posters 3.6k Views 2 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.
  • O Offline
    O Offline
    opengpu2
    wrote on last edited by
    #4

    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

    1 Reply Last reply
    0
    • O Offline
      O Offline
      opengpu2
      wrote on last edited by
      #5

      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

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

        No there's not indeed, however your have QTreeView that might your needs

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

        O 1 Reply Last reply
        0
        • SGaistS SGaist

          No there's not indeed, however your have QTreeView that might your needs

          O Offline
          O Offline
          opengpu2
          wrote on last edited by
          #7

          @SGaist thank you ,i traverse all the items and setHidden true or false by myself...

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

            How many files/folders are you going to handle that way ?

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

            O 1 Reply Last reply
            0
            • SGaistS SGaist

              How many files/folders are you going to handle that way ?

              O Offline
              O Offline
              opengpu2
              wrote on last edited by
              #9

              @SGaist maybe hundreds or even thousands...is there better way?

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

                Then why don't you use a QFileSystemModel ?

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

                O 1 Reply Last reply
                0
                • SGaistS SGaist

                  Then why don't you use a QFileSystemModel ?

                  O Offline
                  O Offline
                  opengpu2
                  wrote on last edited by
                  #11

                  @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...

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

                    You have to use QTreeView/QListView classes when using a model like that.

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

                    O 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      You have to use QTreeView/QListView classes when using a model like that.

                      O Offline
                      O Offline
                      opengpu2
                      wrote on last edited by
                      #13

                      @SGaist ok...but i think i can't use QTreeView...

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

                        Why can't you ?

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

                        O 1 Reply Last reply
                        0
                        • SGaistS SGaist

                          Why can't you ?

                          O Offline
                          O Offline
                          opengpu2
                          wrote on last edited by
                          #15

                          @SGaist already write many code...

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

                            Refactoring might be hard but it's generally a good thing to have a clean code base

                            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