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. QFileDialog::setProxyModel()
Forum Updated to NodeBB v4.3 + New Features

QFileDialog::setProxyModel()

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

    Hello! I use Qt-4.4.3/X11.
    I customizing QFileDialog so that it displays additional virtual drive after root drive "/" in MyComputer.
    In docs reads "QFileDialog::setProxyModel() sets the model for the views to the given proxyModel. This is useful if you want to modify the underlying model; for example, to add columns, filter data or add drives.".
    So I use QFileDialog::setProxyModel() to add drive.
    I create proxyModel as descendant of QSortFilterProxyModel. Now my QFileDialog with proxyModel displays virtual disk fine.
    But double clicking on it does nothing, because proxyIndex for virtual drive have no sourceIndex in source model.
    I need that double clicking on virtual drive handles as usual folder. Any ideas ?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      You will have to translate the virtual index to an index of an actually existing file/directory in the filesystem or provide the data for more virtual files yourself.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • P Offline
        P Offline
        purser
        wrote on last edited by
        #3

        I reimplement all functions to provide data for my virtual files and folders. But double click handler
        QFileDialogPrivate::q enterDirectory() does not ask me for virtual file. It asked source model directly throught mapToSource("here myProxyVirtualIndex").

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          That would be a bug from my point of view then. If it works on a proxy model, it always must ask the proxy model.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • P Offline
            P Offline
            purser
            wrote on last edited by
            #5

            I see this bug also. I not find any samples to use this feature QFileDialog::setProxyModel() to realize extra folders.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              By the way, if you add stuff, you should create a complete own proxy model instead of deriving QSortFilterProxyModel (QSFPM). There are many dependencies inside the QSFPM which may lead to problems (as MapToSource delivers some, from the base impl. unexpected values etc.).

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • P Offline
                P Offline
                purser
                wrote on last edited by
                #7

                Yes, you right. I use QSFPM only temporarily to get working example quickly.
                Fortunately, it works, virtual drive dispalys correct. The main problem inside QFileDialog, it
                ignore proxy for extra folder.
                Workaround is handle double click and use separate view with virtual folder contents, but
                I still hope find better decision.

                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