Mawg
Mawg

Reputation: 40145

How to add a file selection dialog using QT Createor?

As an old Borland C++ Bulder coder who has moved to Linux, I was very pleased to find QT and QT Creator.

But I have fallen at the first hurdle: I have designed a form, with some controls, and added a menu. Now, when the user selects menu File/Open, I would like to display a file selection dialog- and I can't see how.

It's obviously a simple problem, so if someone could point me right, I would be grateful.

Upvotes: 10

Views: 21577

Answers (1)

Ahmed Kotb
Ahmed Kotb

Reputation: 6307

include the QFileDialog

#include <QFileDialog>

then on any method you can write something like this

QString path = QFileDialog::getExistingDirectory (this, tr("Directory"), directory.path());
if ( path.isNull() == false )
{
    directory.setPath(path);
}

for more information see this

Upvotes: 17

Related Questions