Using QFileDialog for creating directories instead of files?
-
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!
-
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());@
-
Yes, that function works perfectly, thanks!
-
There is also a QDir class to handle those things.
greetz -
QDir does not handle the UI side of things. d2uriel's advise is sound though.