The following codes are a good solution to select multiple directories and files in the same QFileDialog. Thanks! Originally Posted by JohannesMunk I just checked; multiselection works: Qt Code: Switch view #include <QtGui> int main(int argc, char *argv[]){ QApplication a(argc, argv); QFileDialog w; w.setFileMode(QFileDialog::DirectoryOnly); w.setOption(QFileDialog::DontUseNativeDialog,true); QListView *l = w.findChild<QListView*>("listView"); if (l) { l->setSelectionMode(QAbstractItemView::MultiSelection); } QTreeView *t = w.findChild<QTreeView*>(); if (t) { t->setSelectionMode(QAbstractItemView::MultiSelection); } return w.exec();} #include <QtGui> int main(int argc, char *argv[]) { QApplication a(argc, argv); QFileDialog w; w.setFileMode(QFileDialog::DirectoryOnly); w.setOption(QFileDialog::DontUseNativeDialog,true); QListView *l = w.findChild<QListView*>("listView"); if (l) { l->setSelectionMode(QAbstractItemView::MultiSelection); } QTreeView *t = w.findChild<QTreeView*>(); if (t) { t->setSelectionMode(QAbstractItemView::MultiSelection); } return w.exec(); } To copy to clipboard, switch view to plain text mode It works no matter what I set the DontUseNativeDialog to. I can't seem to get the native dialog going! Strange! I'm on Win7. Qt4.7. Mingw. Joh
#include <QtGui> int main(int argc, char *argv[]){ QApplication a(argc, argv); QFileDialog w; w.setFileMode(QFileDialog::DirectoryOnly); w.setOption(QFileDialog::DontUseNativeDialog,true); QListView *l = w.findChild<QListView*>("listView"); if (l) { l->setSelectionMode(QAbstractItemView::MultiSelection); } QTreeView *t = w.findChild<QTreeView*>(); if (t) { t->setSelectionMode(QAbstractItemView::MultiSelection); } return w.exec();}
#include <QtGui> int main(int argc, char *argv[]) { QApplication a(argc, argv); QFileDialog w; w.setFileMode(QFileDialog::DirectoryOnly); w.setOption(QFileDialog::DontUseNativeDialog,true); QListView *l = w.findChild<QListView*>("listView"); if (l) { l->setSelectionMode(QAbstractItemView::MultiSelection); } QTreeView *t = w.findChild<QTreeView*>(); if (t) { t->setSelectionMode(QAbstractItemView::MultiSelection); } return w.exec(); }
View Tag Cloud
Forum Rules
Bookmarks