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->setFileMode(QFileDialog::Directory);
    _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) {
    l->setSelectionMode(QAbstractItemView::MultiSelection);
    }
    QTreeView t = _f_dlg->findChild<QTreeView>();
    if (t) {
    t->setSelectionMode(QAbstractItemView::MultiSelection);
    }

    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;
    w.setFileMode(QFileDialog::DirectoryOnly);
    w.setOption(QFileDialog::DontUseNativeDialog,true);
    QListView *lView = w.findChild<QListView*>("listView");
    if (lView)
        lView->setSelectionMode(QAbstractItemView::MultiSelection);
    QTreeView *tView = w.findChild<QTreeView*>();
    if (tView)
        tView->setSelectionMode(QAbstractItemView::MultiSelection);
    w.exec();
    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.