[Interest] Calling reject() on a QFileDialog on Macintosh

Rutledge Shawn Shawn.Rutledge at digia.com
Thu Jun 26 08:03:51 CEST 2014


On 25 Jun 2014, at 21:10, John Weeks <john at wavemetrics.com> wrote:

> 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.

That sounds like a bug.  What do you mean about the modal state, the window is active but you can’t interact with anything in it?  Or it’s not active? 




More information about the Interest mailing list