QFileDialog select multiple directories
Using a QFileDialog, I can allow the user to select one or more files, or to select one directory. Is there any way to allow selecting multiple directories?
I have found this FAQ on the qt-site, but the code there doesn't work (even after fixing the typos).
Any ideas?
thanks,
bepaald
Re: QFileDialog select multiple directories
It seems that the QFileDialog won't do it out of the box. My solution would be to build a new directory picker dialog for your application, supporting multiple directories. By using a QFileSystemModel, you don't have to worry about traversing the file system.
Re: QFileDialog select multiple directories
My guess would be that the solution posted in the FAQ can't work with the OS-native filedialogs, which are used by default.
The native dialog won't have a QListWidget etc..
Try opening a qt one.
Code:
filedialog.
setOption(QFileDialog::DontUseNativeDialog,
true);
Joh
Re: QFileDialog select multiple directories
I just checked; multiselection works:
Code:
#include <QtGui>
int main(int argc, char *argv[])
{
QListView *l
= w.
findChild<QListView
*>
("listView");
if (l) {
}
if (t) {
}
return w.exec();
}
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
Re: QFileDialog select multiple directories
The following codes are a good solution to select multiple directories and files in the same QFileDialog. Thanks!
Quote:
Originally Posted by
JohannesMunk
I just checked; multiselection works:
Code:
#include <QtGui>
int main(int argc, char *argv[])
{
QListView *l
= w.
findChild<QListView
*>
("listView");
if (l) {
}
if (t) {
}
return w.exec();
}
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