PDA

View Full Version : Select multiple files from QFileDialog



jiveaxe
16th February 2009, 14:19
Hi,
I need to open more than one file from a QFileDialog, but with the following code I can open only one file at a time:


QFileDialog dialog(this);
dialog.setDirectory(QDir::homePath());
dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setNameFilter(trUtf8("Splits (*.000 *.001)"));
QStringList fileNames;
if (dialog.exec())
fileNames = dialog.selectedFiles();

What I have missed?

Thanks

jpn
16th February 2009, 14:38
Take a closer look: QFileDialog::FileMode

Lykurg
16th February 2009, 14:39
dialog.setFileMode(QFileDialog::ExistingFiles);

jiveaxe
16th February 2009, 14:48
dialog.setFileMode(QFileDialog::ExistingFiles);

Sorry Lykurg, but have you read my code? The line is still there.

jpn
16th February 2009, 14:53
Sorry Lykurg, but have you read my code? The line is still there.
Can you spot the difference?

talk2amulya
16th February 2009, 14:56
brother, u have used QFileDialog::ExistingFile , while the correct one is QFileDialog::ExistingFiles .. :)

jiveaxe
16th February 2009, 14:57
You are right :o
Maybe I need a break :eek:

Thanks