Selecting Folders using QT5 QTFileDialog

Bhavesh Ramburn - Jan 22 '22 - - Dev Community

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
. . . . . . . . . .
Terabox Video Player