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. Non-Traverseable QFileDialog
QtWS25 Last Chance

Non-Traverseable QFileDialog

Scheduled Pinned Locked Moved Solved General and Desktop
qfiledialog
11 Posts 2 Posters 4.5k Views
  • 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.
  • D Offline
    D Offline
    DougyDrumz
    wrote on last edited by
    #1

    This is in reference to http://stackoverflow.com/questions/12169878/limit-directory-traversal-in-qfiledialog

    I tried ololoepepe's code. It compiled, first time, with no issues. The problem I'm having is getting it to work for me. Here's what I did:

    ...
    FileDialog *myFD = new FileDialog(this);
    ...
    myFD->setTopDir(dir);
    QString dirName = myFD->getExistingDirectory(this, "Title", dir);
    ...
    

    I used cout to show what's being called, and it seems logical. The only problem is, no matter what I do, nothing changes in the dialog. I've even hard-coded things like:

    ...
    findChild<QtoolButton *>("toParentButton")->setEnabled(false);
    ...

    to no avail. What am I missing? I tried to look at her example, but that link is obsolete.

    What I really want to do is have a directory list that is completely non-traversable. Perhaps there's an easier way to do this?

    Dougy Drumz

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

      Hi,

      getExisitingDirectory is a static function so all the setup you do before is not applied at all. You have to set it up correctly and then call exec on it.

      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
      1
      • D Offline
        D Offline
        DougyDrumz
        wrote on last edited by
        #3

        Great! Thanks! Might you have a simple example? I'm fairly new to Qt.

        Dougy Drumz

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

          QFileDialog's documentation contains a step by step example

          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
          1
          • D Offline
            D Offline
            DougyDrumz
            wrote on last edited by
            #5

            That did the trick. Thanks again.

            Dougy Drumz

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

              You're welcome !

              Since you have it working now, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)

              Also, while browsing the forum consider up-voting answers that helped you, that will make them easier to find for other users :)

              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
              1
              • D Offline
                D Offline
                DougyDrumz
                wrote on last edited by
                #7

                I can disable "lookInCombo" and "sidebar" but not the buttons to the right of "lookInCombo" unless I select a directory and use the currentChanged signal. Is there a signal for when the QFileDialog pops up? Is there a method to select the first item in the list (by index, not by name)? Any other ideas?

                Also, I would like to either disable double-click in the directory list or reassign it to choose the directory instead of displaying the set of files beneath that directory. How would I go about getting this done?

                Dougy Drumz

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

                  With all the modifications you are doing, why not make a complete custom dialog ?

                  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
                  1
                  • D Offline
                    D Offline
                    DougyDrumz
                    wrote on last edited by
                    #9

                    That's a good idea, and I was thinking along those lines. However, is it better to inherit from QDialog or QFileDialog? It seems I'm 90% there using QFileDialog as my baseline. Right now I'm just experimenting, but I plan to incorporate it all into a custom dialog.

                    Out of curiosity, are child names like "lookInCombo" and "sidebar" documented anywhere, or do you have to search through the Qt code? If so, where's the best place to find the code? It seems like if I knew the child name of what ever houses the buttons to the left of "looksInCombo" (something like "buttonBox"?) I could just disable that and I'm only left with the double-click issue. However, I'm new to customizing Qt, so any suggestions would be greatly appreciated.

                    Dougy Drumz

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

                      You can also take a look at QFileDialog's non-native implementation for either starter or ideas.

                      No they are not documented because those are implementation details that can change at any time.

                      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
                      1
                      • D Offline
                        D Offline
                        DougyDrumz
                        wrote on last edited by
                        #11

                        I got it all working. I modified ololoepepe's class (http://stackoverflow.com/questions/12169878/limit-directory-traversal-in-qfiledialog) a bit for my pourposes and set the double click interval to 0 (essentially disabling double clicks). Thanks again.

                        Dougy Drumz

                        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