DEV Community

Bhavesh Ramburn
Bhavesh Ramburn

Posted on

Selecting Folders using QT5 QTFileDialog

Following the documentation here we see that it is pretty easy for us to select a folder and return a string of the selected file. This is the easiest way to collect folders and print the value into a textfield:

QString fileName = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
                                                    QDir::currentPath(),
                                                    QFileDialog::ShowDirsOnly
                                                    | QFileDialog::DontResolveSymlinks);

    ui->textEdit->setText(fileName);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)