Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
5.2.1
-
None
-
Windows7, Visual Studio 2010
Description
I noticed that calling a static member of QFileDialog unsets the active window.
Static members of QMessageBox apparently do not have this issue.
Workaround: calling qApp->processEvents(); fixes the problem
Example:
#include <QApplication> #include <QFileDialog> #include <QVBoxLayout> #include <QPushButton> class Dialog : public QDialog { Q_OBJECT public: Dialog() { QVBoxLayout* layout = new QVBoxLayout(); QPushButton* button = new QPushButton( "Open popup", this ); layout->addWidget( button ); connect( button, SIGNAL(clicked()), this, SLOT(openPopup()) ); } public slots: void openPopup() { QWidget* widget = qApp->activeWindow(); QFileDialog::getExistingDirectory( widget, // pass widget or NULL: same behaviour "toto", "tata" ); // qApp->processEvents(); QWidget* widget2 = qApp->activeWindow(); // here widget == this and widget2 == NULL. {color:red}THAT'S THE BUG!{color} // If called qApp->processEvents(), widget == widget2 == this } }; int main( int argc, char* argv[] ) { QApplication app( argc, argv ); Dialog dlg; dlg.show(); return app.exec(); }
Attachments
For Gerrit Dashboard: QTBUG-38414 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
83947,1 | Fix crash when accessing QFileDialog::selectedFiles() before widgets exist. | stable | qt/qtbase | Status: MERGED | +2 | 0 |
83948,1 | Stabilize tst_qfiledialog. | stable | qt/qtbase | Status: MERGED | +2 | 0 |