Reputation: 3124
I have a QFileDialog in Qt for saving a file.
It is not smmiting signals. I connect it via QFileDialog diag(this); ...
connect(
dialog, SIGNAL(filterSelected(const QString&)),
this, SLOT(saveAsDiagFilterSelected(const QString&)),
Qt::QueuedConnection);
Then call it with exec()
. The saveAsDiagFilterSelected
is never called.
What might be wrong?
This is how I create my dialog:
dialog = new QFileDialog(this);
dialog->setFileMode(QFileDialog::AnyFile);
dialog->setNameFilters(filterList);
dialog->setAcceptMode(QFileDialog::AcceptSave);
dialog->setWindowTitle(windowTitle);
I tried implementing the new signal API (as suggested in comments):
connect(
dialog, &QFileDialog::filterSelected,
this, &MainWindow::saveAsDiagFilterSelected);
but still no results.
Update
Found out that using the OS native dialog (I'm under Linux, dont know if this happens in other SO's), is creating the problem. If I do
dialog->setOption(QFileDialog::DontUseNativeDialog, true);
the signal is emmited. How can I workaround this?
Upvotes: 1
Views: 777
Reputation: 98425
The native dialog on your platform does not inform the user about filter changes, so there's nothing for Qt to emit signals on - it isn't possible with that particular native dialog. Or perhaps the requisite functionality isn't implemented in Qt. This behavior is platform specific. It works on Windows at least.
Upvotes: 2
Reputation: 5600
Try setting slots/signals like this:
connect(
dialog, SIGNAL(filterSelected(QString)),
this, SLOT(saveAsDiagFilterSelected(QString)),
Qt::QueuedConnection);
Upvotes: 1