문제

I have two QMainWindows. I would like when a QMessageBox is displayed on a QMainWindow with an exec(), the other QMainWindow isn't blocked.

The two QMainWindow must be independent.

How do this ?

도움이 되었습니까?

해결책

It has nothing to do with QThread, the Qt documentation states that you can have only ONE GUI thread in a QT application.

What you should do is to set the modality flag to make the dialog modal, so it will be modal related to its parent window. Before executing the dialog, call:

pDialog->setWindowModality( Qt::WindowModal );

And don't forget to set a proper parent for your dialog object.

Qt documentation states: -

Modal Dialogs

A modal dialog is a dialog that blocks input to other visible windows in the 
same application. Dialogs that are used to request a file name from the user or 
that are used to set application preferences are usually modal. Dialogs can be 
application modal (the default) or window modal.

다른 팁

Use the show() method to display each QMainWindow instead of exec().

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top