Unsolved Exclude a window from being checked if it is closed or not?
-
@JonB Thanks! I will see if I can achieve the same result by any other means.
-
@Pl45m4 My tool widget is an independent window, I cannot assign MainWIndow as its parent.
-
@CJha said in Exclude a window from being checked if it is closed or not?:
I cannot assign MainWIndow as its parent.
You cannot or you don't want to (due to your app design structure)?
Because I believe you can :) Even aQMainWindow
can have a parent -
@Pl45m4 Yes, I don't want to because of my app structure. This tool window is supposed to be completely independent of any other part of the app. MainWindow is not aware that this tool window exists, and the tool window is not aware that MainWindow exists.
-
@CJha said in Exclude a window from being checked if it is closed or not?:
MainWindow is not aware that this tool window exists
So @mrjj 's solution won't work either?!
Tricky. Then it might not be possible ;-)
-
@CJha
Hi
But there is not that many options.
Either the tool window is closed by being owned by a parent or
you close it manually when you want to.
If you don't want a pointer in MainWindow to the tool, you could use signal / slot
so MainWindow will emit ImClosing and others can react to that. -
@Pl45m4 Yes, that's right. That's why I posted this question :)
-
@mrjj Thanks! that's a solution. But, I am put a lot of constraints on the tool window. It is created just after
QApplication
object is created and before theQMainWindow
object is created. I would like it to be completely independent, kind of "make it and forget it" fashion, and so I am not connecting any signals to my tool window except for signals fromQApplication
(and therefore fromQGuiApplication
andQCoreApplication
). I am trying right now to see if I can detect inside my tool window if it's the only window, by hooking up to theQGuiApplication::focusWindowChanged
signal, if it is the only window then I will close it. -
@CJha
Hi
Ok. no signals then :)Try use
QWidgetList QApplication::topLevelWidgetsand see if ToolWindow is listed.
I imagine then when MainWin is close the size of list is 1
focusWindowChanged could also work. if its not fired if the user clicks on some other window.
-
@mrjj Thanks, I need a signal to know when to check
QApplication::topLevelWidgets
, I think I will create an event filter and apply it toQApplication
and this way I can hook on to any close event that is generated in the application. I just tried withfocusWindowChanged
signal, it works as long my tool window is not minimized.