简体   繁体   中英

How to make QFileDialog not modal in Qt5?

In previous versions of Qt we were able to use following constructor of file dialog:

QFileDialog(QWidget * parent = 0, const char * name = 0, bool modal = FALSE)

So, it looks like it was possible to make non-modal file dialog. But now (in Qt5) we haven't such parameters in constructor. Also QFileDialog ignores setWindowModality(Qt::NonModal); and setModal(false); (I've checked, that if windowModality() == Qt::NonModal && isModal() == false , file dialog window is still modal).

Do you have ideas, how to make my file dialog non-modal?

Details: my file dialog inherited from QFileDialog. It works absolutely as expected. The only thing I need is to make it non-modal, but I can't find solution on SO and on qt-project. Thank you in advance.

The "problem" is that you open the file dialog as a modal window by calling QDialog::open() function. According to the Qt docs for QDialog::open() :

Shows the dialog as a window modal dialog, returning immediately.

To make the file dialog non modal simply open it with QDialog::show() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM