0

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 ?

Juergen
  • 12,378
  • 7
  • 39
  • 55
artoon
  • 729
  • 2
  • 14
  • 41

2 Answers2

2

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.
TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
evilruff
  • 3,947
  • 1
  • 15
  • 27
0

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

RobbieE
  • 4,280
  • 3
  • 22
  • 36
  • QMainWindows are displayed with show. And I need to use exec for QMessageBox to treat the result. – artoon Aug 22 '13 at 07:47