2

I am using QFileDialog as

filename = QFileDialog::getExistingDirectory(this,"Select Image File: ",dataDir,0);

I want that I can check files inside folder before selecting it. function getExistingDirectory() is setting QFileDialog::ShowDirsOnly as a default option. I checked in docs there is no any option that do opposite of this. So I set last parameter 0. But now it is not using native dialog. I want to use native dialog with this. I have no clue how to do this cause no flag found in options for UseNativeDialog. Please help.

Tab
  • 785
  • 2
  • 11
  • 27

2 Answers2

1

Try creating the file dialog on your own, something like:

QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::Directory);
dialog.setViewMode(QFileDialog::Detail);
dialog.setDirectory(datadir);
dialog.exec();
Sebastian Lange
  • 3,879
  • 1
  • 19
  • 38
1

The code by Sebastian should create a native dialog, unless you make a line such as:

dialog.setOption(QFileDialog::DontUseNativeDialog, true);

However, I have not been able to get this working under Windows, even though the documentation says that the QFileDialog::Directory option should display files by default. Not only that, but doing:

qDebug() << dir_selector.testOption(QFileDialog::ShowDirsOnly);

displays false on my system, indicating that there is probably a bug somewhere.

deltatango
  • 166
  • 1
  • 6