Solved QMainWindow and its children vs visibility at focus change/minimizing
-
Hello,
I have a
QMainWindow
instance with bunch ofQDialog
s andQWidget
s set as its childern. User may open them by clickin some actions on menubar. What is happening, that in fact I don't want to be happenin:- when I minimize main window its children are minimized as well (I guess because they are its children)
- when I have some dialog/widget opened (visible) it stays ON TOP of the main window even if I click in the main windows area (focus thingy i guess)
My question is:
- is there a non-complicated solution to fix this behaviour? Idk.. like settings a flag? something like that, I cannot find anything in docs (at least so far)
What I came across during searching:
- 'orphaning' children :D (setting their parent to Q_NULLPTR) inside
stateChanged
event and turning it back again depending on the event type.
I did not test/used it yet since out of curiosity I wanted to ask you guys about it? Do you think above solution is sensible enough to be used or are there any other better ones?
Best Regards,
M. -
Hi
Have you tried simply not to give the dialogs a parent?MyDialog * dia= new MyDialog ();
You will need to delete them your self when app is closing.
-
Simplest solutions are the best - thank you!
I kinda feel really dumb now :D
Anyway - solved. -
@michelson
Well often :)
There was a thread not so long ago talking
about how to delete the dialogs later.
If you make them members, its pretty basic. -
Can you point me to this thread (just in case - I may find something usefull there)?