Important: Please read the Qt Code of Conduct -

QFileDialog : how to set option to show content of folder in getExistingDirectory()

  • 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.

  • Hi,
    What do you want to use? You want to know the directory, but also show the files in it, so the user is able to check the contents?
    Ok, that's possible.
    enum QFileDialog::FileMode is the enum to use, and setFileMode the fucntion.
    So in code:
    QFileDialog::getExistingDirectory(this, "bla", "Dirstring", QFileDialog::Directory);
    Set the option to QFileDialog::Directory and you will see directories and files.
    More options are available for filemode etc. Simple to use the | between them!

  • It is showing error : cannot convert parameter 4 from 'QFileDialog::FileMode' to 'QFileDialog::Options'

  • Lifetime Qt Champion


    What OS/Qt version are you using ?

  • Hi SGaist,

    I am using Qt 4.8.3 on Windows7

Log in to reply