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::getExistingDirectoryUrl opening remote dirs
Forum Updated to NodeBB v4.3 + New Features

QFileDialog::getExistingDirectoryUrl opening remote dirs

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.7k 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.
  • musimbateM Offline
    musimbateM Offline
    musimbate
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      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

      musimbateM 1 Reply Last reply
      2
      • A ambershark

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

        musimbateM Offline
        musimbateM Offline
        musimbate
        wrote on last edited by
        #3

        @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
        0
        • musimbateM musimbate

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

          A Offline
          A Offline
          ambershark
          wrote on last edited by
          #4

          @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

          musimbateM 1 Reply Last reply
          3
          • A ambershark

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

            musimbateM Offline
            musimbateM Offline
            musimbate
            wrote on last edited by
            #5

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

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved