Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QFileDialog::getExistingDirectoryUrl opening remote dirs

    General and Desktop
    2
    5
    970
    Loading More Posts
    • 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.
    • musimbate
      musimbate last edited by

      Hi,
      I can't seem to find the difference between the two flavors of the static methods provided by QFileDialog. The docs state that the QUrl flavor can even work on remote files/directories but can't seem to see the differences in the dialogs generated by the code snippets below :

      First

      QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
                                                           "/home",
                                                           QFileDialog::ShowDirsOnly
                                                           | QFileDialog::DontResolveSymlinks);
      

      Second

      QUrl url = QFileDialog::getExistingDirectoryUrl(this, tr("Open Directory"));
      

      The Displayed dialog looks like this (Windows)
      0_1526869870120_18e078d4-9077-4b23-bb42-5128ac63dd22-image.png

      Would be great if somebody helped clarify. I must be missing something here.

      Why join the navy if you can be a pirate?-Steve Jobs

      1 Reply Last reply Reply Quote 0
      • A
        ambershark last edited by

        The first one takes a QString for the path and returns a QString. The second one uses QUrl for both it's starting path and returns a QUrl.

        They both do the same thing because /home is not a valid path on windows for the first one so you get your last set directory (D: based on the screen shot). In the second example you don't set a starting path/url so you get the same thing which is D:.

        My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

        musimbate 1 Reply Last reply Reply Quote 2
        • musimbate
          musimbate @ambershark last edited by

          @ambershark
          Thanks for the reply. Sorry for my messy code snippets, it was a quick run to see how these methods work. What I really want to know is what they mean by

          "The main difference with QFileDialog::getExistingDirectory() comes from the ability offered to the user to select a remote directory"
          In the doc. Is there any indication in the UI that the user can choose a remote directory? is there needed settings to pass in to have the dialog provide that ability ? Basically a simple code example of how to use this method to select remote dirs would clear the fog a bit.

          Why join the navy if you can be a pirate?-Steve Jobs

          A 1 Reply Last reply Reply Quote 0
          • A
            ambershark @musimbate last edited by

            @musimbate Oh I understand... so with a QUrl you can use any type of protocol for remote access.. For instance you could use ftp. So you could set up a dialog like:

            auto url = QFileDialog::getExistingDirectoryUrl(this, tr("Open Directory"), QUrl("ftp://my.ftp.com"));
            

            You can limit the protocols you allow but setting them as supportedSchemes too.

            See QUrl docs for details on forming and using QUrl and schemes.

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            musimbate 1 Reply Last reply Reply Quote 3
            • musimbate
              musimbate @ambershark last edited by

              @ambershark
              A ha! Now it all makes sense. This makes it clear. Thanks a lot.

              Why join the navy if you can be a pirate?-Steve Jobs

              1 Reply Last reply Reply Quote 1
              • First post
                Last post