Qt World Summit: Register Today!

is there any way to get multiple Dirs using getexistingdirectory ?

  • is there any way to get multiple Dirs using getexistingdirectory ??

  • just a guess, but maybe you can use some kind ofsetFilter(QDir::Dirs) and selectedUrls() or selectedFiles()

  • @sneubert getexistingdirectory or getopenfilenames is static API

  • @opengpu2

    sorry, if you cant create an object of QFileDialog, I think it´s not possible

  • @sneubert
    @QFileDialog* _f_dlg = new QFileDialog(this);
    _f_dlg->setOption(QFileDialog::DontUseNativeDialog, true);

    // Try to select multiple files and directories at the same time in QFileDialog
    QListView l = _f_dlg->findChild<QListView>("listView");
    if (l) {
    QTreeView t = _f_dlg->findChild<QTreeView>();
    if (t) {

    int nMode = _f_dlg->exec();
    QStringList _fnames = _f_dlg->selectedFiles();@

  • Try this you can select/Deselect the directories. since native directory file browser won't support the multiple directory selection, need to set the flags DontUseNativeDialog, its exactly what @opengpu2 has said.

    QFileDialog w;
    QListView *lView = w.findChild<QListView*>("listView");
    if (lView)
    QTreeView *tView = w.findChild<QTreeView*>();
    if (tView)
    qDebug() << " Selected Directories :  " << w.selectedFiles();

  • selectedFiles can return the selected Dirs and Files....
    but these are in QStringList....how can i distinguish the dir from the files?
    thank you!

Log in to reply