DEV Community

Bhavesh Ramburn
Bhavesh Ramburn

Posted on

2 3

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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs