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. I want to implement a file explorer list in the form of a windows form.
Forum Updated to NodeBB v4.3 + New Features

I want to implement a file explorer list in the form of a windows form.

Scheduled Pinned Locked Moved Unsolved General and Desktop
27 Posts 3 Posters 8.8k 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.
  • P Offline
    P Offline
    PaNi
    wrote on last edited by
    #1

    I currently implementing a file explorer similar to the Windows file explorer.
    I've implemented all the features, but I couldn't implement the last remaining folder tree shape.
    What I'm currently using is using QFileSystemModel, and currently I'm outputting only the driver with this.
    So, in addition to the drive, I want to output more folders in the window, such as documents, videos, and photos.
    I've been searching for several months, but I couldn't find a solution, and I saw a lot of advice to use a proxy model, but I'm currently too new to implement it.
    I am not good at English, so I wrote it using a translator, and I hope you will be kind.

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

      Hi and welcome to devnet,

      If I understand correctly, you want to have special folders in addition to the ones shown by QFileSystemModel. For that, you could for example implement a custom model that shows what you want and then use a proxy that combines both your custom model and the one showing your filesystem.

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

      P 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi and welcome to devnet,

        If I understand correctly, you want to have special folders in addition to the ones shown by QFileSystemModel. For that, you could for example implement a custom model that shows what you want and then use a proxy that combines both your custom model and the one showing your filesystem.

        P Offline
        P Offline
        PaNi
        wrote on last edited by PaNi
        #3

        @SGaist
        Thank you for your answer, SGaist! The time is different. That's why I'm answering
        From what I've explored, some people recommend using the SortproxyModel and others recommend using the AbsoluteproxyModel, so can I ask you which proxy model should I use?

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

          What is the AbsoluteProxyModel ?

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

          P 1 Reply Last reply
          0
          • SGaistS SGaist

            What is the AbsoluteProxyModel ?

            P Offline
            P Offline
            PaNi
            wrote on last edited by
            #5

            @SGaist
            Oh, I'm sorry. It was the QAbstract Proxy Model, but I said it wrong.

            JonBJ 1 Reply Last reply
            0
            • P PaNi

              @SGaist
              Oh, I'm sorry. It was the QAbstract Proxy Model, but I said it wrong.

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by JonB
              #6

              @PaNi
              A QSortFilterProxyModel is a specialized QAbstractProxyModel which provides sorting and/or filtering behaviour on the source model. If you want either/both of those then by all means use a QSFPM, if not use something else derived from QAPM, including possibly something you write yourself.

              From your description I'm not convinced QSFPM is relevant to your question. Sorting is not an issue you mention. Filtering is used to reduce the source model items. But you are saying (I think) you want to add additional elements over what QFileSystemModel is supplying? So reducing is not your objective.

              P 1 Reply Last reply
              0
              • JonBJ JonB

                @PaNi
                A QSortFilterProxyModel is a specialized QAbstractProxyModel which provides sorting and/or filtering behaviour on the source model. If you want either/both of those then by all means use a QSFPM, if not use something else derived from QAPM, including possibly something you write yourself.

                From your description I'm not convinced QSFPM is relevant to your question. Sorting is not an issue you mention. Filtering is used to reduce the source model items. But you are saying (I think) you want to add additional elements over what QFileSystemModel is supplying? So reducing is not your objective.

                P Offline
                P Offline
                PaNi
                wrote on last edited by PaNi
                #7

                @JonB
                Thank you for contacting me, JonB. Sorry for the late reply.
                Yes, that's right. However, when I searched, I was told that I had to add it using the two proxy models, maybe because I got the wrong keyword.
                Currently, the drive output is successful using the QFilesystemModel, but the virtual folder should be envisioned above, just like Window File Explorer. But I understand that it is difficult to implement a Windows virtual folder.
                So I think we should go in the direction of adding row and adding rootpath, but I'm a beginner, so I'm not sure how to get it out even if I'm thinking about how to design it.

                JonBJ 1 Reply Last reply
                0
                • P PaNi

                  @JonB
                  Thank you for contacting me, JonB. Sorry for the late reply.
                  Yes, that's right. However, when I searched, I was told that I had to add it using the two proxy models, maybe because I got the wrong keyword.
                  Currently, the drive output is successful using the QFilesystemModel, but the virtual folder should be envisioned above, just like Window File Explorer. But I understand that it is difficult to implement a Windows virtual folder.
                  So I think we should go in the direction of adding row and adding rootpath, but I'm a beginner, so I'm not sure how to get it out even if I'm thinking about how to design it.

                  JonBJ Online
                  JonBJ Online
                  JonB
                  wrote on last edited by JonB
                  #8

                  @PaNi
                  Then I think the approach should be as @SGaist said:

                  For that, you could for example implement a custom model that shows what you want and then use a proxy [derived from QAbstractProxyModel ] that combines both your custom model and the one showing your filesystem

                  P 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @PaNi
                    Then I think the approach should be as @SGaist said:

                    For that, you could for example implement a custom model that shows what you want and then use a proxy [derived from QAbstractProxyModel ] that combines both your custom model and the one showing your filesystem

                    P Offline
                    P Offline
                    PaNi
                    wrote on last edited by PaNi
                    #9

                    @JonB
                    So I searched that way, but the qt version I am using is not supported, so I am looking for another way...crying

                    JonBJ 1 Reply Last reply
                    0
                    • P PaNi

                      @JonB
                      So I searched that way, but the qt version I am using is not supported, so I am looking for another way...crying

                      JonBJ Online
                      JonBJ Online
                      JonB
                      wrote on last edited by
                      #10

                      @PaNi
                      Since QAbstractProxyModel is available in every version of Qt I don't know what you searched.

                      P 1 Reply Last reply
                      1
                      • JonBJ JonB

                        @PaNi
                        Since QAbstractProxyModel is available in every version of Qt I don't know what you searched.

                        P Offline
                        P Offline
                        PaNi
                        wrote on last edited by
                        #11

                        @JonB
                        Oh! Is that possible? I listened to SGaist and searched for related keywords and found a model other than QAbstractProxyModel. That's why I said that

                        JonBJ 1 Reply Last reply
                        0
                        • P PaNi

                          @JonB
                          Oh! Is that possible? I listened to SGaist and searched for related keywords and found a model other than QAbstractProxyModel. That's why I said that

                          JonBJ Online
                          JonBJ Online
                          JonB
                          wrote on last edited by
                          #12

                          @PaNi
                          QAbstractProxyModel is there for you to subclass/derive from. You need to first write a class to deliver the "extra"/"virtual" nodes you want (probably deriving from QAbstractItemModel). Then you might derive from a QAbstractProxyModel to "merge"/"combine" this model with the existing QFileSystemModel, to "augment" it for the (top-level?) nodes provided by your extra/virtual nodes, so that they are presented as a single, combined model to be used by e.g. a QTreeView.

                          P 1 Reply Last reply
                          2
                          • JonBJ JonB

                            @PaNi
                            QAbstractProxyModel is there for you to subclass/derive from. You need to first write a class to deliver the "extra"/"virtual" nodes you want (probably deriving from QAbstractItemModel). Then you might derive from a QAbstractProxyModel to "merge"/"combine" this model with the existing QFileSystemModel, to "augment" it for the (top-level?) nodes provided by your extra/virtual nodes, so that they are presented as a single, combined model to be used by e.g. a QTreeView.

                            P Offline
                            P Offline
                            PaNi
                            wrote on last edited by
                            #13

                            @JonB
                            I know it can be rude, but if you don't mind, can you give me a simple example? I'm in such a desperate mood that I'm asking you...

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

                              KDE has several model classes, one of which concatenates the rows of several other models.

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

                              P 1 Reply Last reply
                              1
                              • SGaistS SGaist

                                KDE has several model classes, one of which concatenates the rows of several other models.

                                P Offline
                                P Offline
                                PaNi
                                wrote on last edited by
                                #15

                                @SGaist
                                I'm trying to implement it in a different way because the version I'm writing is not the one that supports that feature. The proxy model is hard to access, so I'm trying to implement it using widgets.

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

                                  Support which feature ?

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

                                  P 1 Reply Last reply
                                  1
                                  • SGaistS SGaist

                                    Support which feature ?

                                    P Offline
                                    P Offline
                                    PaNi
                                    wrote on last edited by PaNi
                                    #17

                                    @SGaist
                                    The version I am using now is qt 5.12 version.
                                    Therefore, I think we can use all the features provided by this version.

                                    1 Reply Last reply
                                    0
                                    • P PaNi

                                      @SGaist
                                      I'm trying to implement it in a different way because the version I'm writing is not the one that supports that feature. The proxy model is hard to access, so I'm trying to implement it using widgets.

                                      JonBJ Online
                                      JonBJ Online
                                      JonB
                                      wrote on last edited by
                                      #18

                                      @PaNi said in I want to implement a file explorer list in the form of a windows form.:

                                      I'm trying to implement it in a different way because the version I'm writing is not the one that supports that feature.

                                      The question is: what feature that is not supported in Qt 5.12 are you talking about?

                                      The proxy model is hard to access, so I'm trying to implement it using widgets.

                                      There is little connection between "proxy models" and "widgets". It is hard to imagine what could be accessed from widgets that would resolve a need for proxy models.

                                      P 1 Reply Last reply
                                      0
                                      • JonBJ JonB

                                        @PaNi said in I want to implement a file explorer list in the form of a windows form.:

                                        I'm trying to implement it in a different way because the version I'm writing is not the one that supports that feature.

                                        The question is: what feature that is not supported in Qt 5.12 are you talking about?

                                        The proxy model is hard to access, so I'm trying to implement it using widgets.

                                        There is little connection between "proxy models" and "widgets". It is hard to imagine what could be accessed from widgets that would resolve a need for proxy models.

                                        P Offline
                                        P Offline
                                        PaNi
                                        wrote on last edited by
                                        #19

                                        @JonB
                                        Oh! Not in the version meant that the proxy model that combines multiple rows for the KDE model supports from version 5.13 and the widget implementation is that I can't understand the proxy model at all, so I'm only trying to build a folder tree using TreeWidget.
                                        So we're trying to set the desired address value so that a tree can be created from a folder for that address.
                                        But even that's not easy.

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

                                          If you want to show the structure of a particular subfolder, configure the view accordingly. There's an example of that in QFileSystemModel's details.

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

                                          P 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