Raise modal QDialog when user tries to activate MainWindow

610 Views Asked by At

we have a QMainWindow containing several QDialogs which are opened using exec() and are therefore modal (which is the desired behaviour).

Now, when the user has one of these dialogs open, chooses to do interact with some external program (e.g. webbrowser) which overlaps the Dialog but not the MainWindow and then tries to return to our program, he is not able to to that by clicking the visible area of the main window due to the modal dialog. In order to return he needs to move/minimize other windows obstructing the view to the QDialog or activating it by using the taskbar. This may give the impressing of the program being frozen (especially if some time has passed and the user is not aware of the opened dialog).

I overloading various focus/mouse events in the main window / dialogs to raise() the QDialog in such a case but I could not found one being activated when clicking the main window as the dialog is shown. Does someone know a solution for this? I assume its something easy I must have overlooked so far.

1

There are 1 best solutions below

1
On BEST ANSWER

Make sure that the QDialogs get the correct parent (the main window) in the constructor. That should fix the problem.