[Interest] Calling reject() on a QFileDialog on Macintosh
John Weeks
john at wavemetrics.com
Wed Jun 25 21:10:35 CEST 2014
We use QFileDialog::getOpenFileName() to get the native file dialog on Macintosh. If you hit Escape, the dialog closes (as it should).
If I call QDialog::reject() or even if I use this code:
QFileDialog * dialog = qobject_cast<QFileDialog *>(activeModalWidget);
QKeyEvent * event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier, QString(),0,0);
QApplication::postEvent(dialog, event);
event = new QKeyEvent(QEvent::KeyRelease, Qt::Key_Escape, Qt::NoModifier, QString(),0,0);
QApplication::postEvent(dialog, event);
the dialog closes, but with Qt 5.3 it leaves the application in some sort of modal state. This puzzles me- hitting the Escape key works fine. What's the difference?
By the way, this works as I expect with Qt 4.8.6.
-John Weeks
More information about the Interest
mailing list