Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a file selection dialog using QT Createor?

Tags:

qt-creator

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.

like image 289
Mawg says reinstate Monica Avatar asked Jan 15 '10 13:01

Mawg says reinstate Monica


1 Answers

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

like image 96
Ahmed Kotb Avatar answered Oct 24 '22 15:10

Ahmed Kotb