The following codes are a good solution to select multiple directories and files in the same QFileDialog. Thanks!

Quote Originally Posted by JohannesMunk View Post
I just checked; multiselection works:

Qt Code:
  1. #include <QtGui>
  2.  
  3. int main(int argc, char *argv[])
  4. {
  5. QApplication a(argc, argv);
  6. w.setFileMode(QFileDialog::DirectoryOnly);
  7. w.setOption(QFileDialog::DontUseNativeDialog,true);
  8. QListView *l = w.findChild<QListView*>("listView");
  9. if (l) {
  10. l->setSelectionMode(QAbstractItemView::MultiSelection);
  11. }
  12. QTreeView *t = w.findChild<QTreeView*>();
  13. if (t) {
  14. t->setSelectionMode(QAbstractItemView::MultiSelection);
  15. }
  16. return w.exec();
  17. }
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