Here the code:
dialog = new QFileDialog(this);
dialog->setFileMode(QFileDialog::ExistingFiles);
connect(dialog, SIGNAL(currentChanged(const QString&)),
this, SLOT(dialogSelectionChanged(const QString&)));
void MainWindow::dialogSelectionChanged(const QString& file)
{
QStringList selected = dialog->selectedFiles();
}
The problem is that
fileSelected(const QString&)andfilesSelected(const QStringList&)emitted only after I press 'Open' button.currentChanged(const QString&)passes only newly selected file- and
selectedFiles()returns me in that case files that were selected at previous step. Probably dialog updates files after it emitscurrentChanged(const QString&).
That is why I don't know how to trace currently selected files. Another problem is that I don't know so far how to cancel selection of last selected file if user exceeds limit of allowed selections.
I have seen couple of examples where people implement custom features either with QProxyModel or with custom implementation of QFileDialog but I'm not sure what will fit my needs best.