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. Using QFileDialog for creating directories instead of files?

Using QFileDialog for creating directories instead of files?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 5.8k 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.
  • G Offline
    G Offline
    godplusplus
    wrote on last edited by
    #1

    Hello everyone. I've been using QFileDialog for opening and creating different files.
    However, right now I need to do the following:
    -I need to create a new folder (let's call it "project folder") with some files inside (I already have this working)
    -The user needs to choose the location of where to create that folder (no clue how to do this)

    I need to be able to show a dialog from which the user can choose the location in which my application will then create the project folder I mentioned.

    How can I do this? Should I use getSaveFileName from QFileDialog? If so, which are the parameters I need to send? Or which class can I use?

    A code snippet or a link would really help me out! Thanks!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      d2uriel
      wrote on last edited by
      #2

      Try using static method of this class named "getExistingDirectory()":http://developer.qt.nokia.com/doc/qt-4.8/qfiledialog.html#getExistingDirectory . Hope that's what you needed.

      @QString directory = QFileDialog::getExistingDirectory(this, tr("Show me a dir"), QCoreApplication::applicationDirPath());@

      "Do not judge, and you will never be mistaken." - Jean-Jacques Rousseau

      1 Reply Last reply
      0
      • G Offline
        G Offline
        godplusplus
        wrote on last edited by
        #3

        Yes, that function works perfectly, thanks!

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

          There is also a QDir class to handle those things.
          greetz

          Greetz, Jeroen

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            QDir does not handle the UI side of things. d2uriel's advise is sound though.

            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