Taskbar click event
-
Dear fellow forum members, good morning. I have a problem that after Qt program is minimized, I need to restore the normal display when I click software in the taskbar. This is done by default. But I need to do a few things before I go back to the default display. So you need to know in eventFilter how do you determine if it's a taskbar click event?
-
Dear fellow forum members, good morning. I have a problem that after Qt program is minimized, I need to restore the normal display when I click software in the taskbar. This is done by default. But I need to do a few things before I go back to the default display. So you need to know in eventFilter how do you determine if it's a taskbar click event?
@Nan-Feng
What is a "taskbar"? Something in your windowing system? A Windows taskbar on the desktop if you are under Windows?Qt isn't going to know/tell you that something was caused by/emanated from some windowing desktop or taskbar. Does clicking the taskbar just toggle between window mimimize and window restore? I can only think of
showEvent()
orQShowEvent
where event->spontaneous() will be true to tell you the event came from the windowing system rather than your own code callingshow...()
. -
Clicking an icon on a taskbar is not the only way to activate your app. You can alt-tab to it or it can be activated by the OS when all other apps are closed, some other app might send your window a minimize/maximize/restore message etc. In general don't rely on what's happening outside of your app in the OS. Some update will come out that changes that behavior and your app will stop working correctly.
In the event filter you can check for QWindowStateChangeEvent. This will tell you when your app is minimized, maximized or restored, no matter what caused it.
-
Clicking an icon on a taskbar is not the only way to activate your app. You can alt-tab to it or it can be activated by the OS when all other apps are closed, some other app might send your window a minimize/maximize/restore message etc. In general don't rely on what's happening outside of your app in the OS. Some update will come out that changes that behavior and your app will stop working correctly.
In the event filter you can check for QWindowStateChangeEvent. This will tell you when your app is minimized, maximized or restored, no matter what caused it.
@Chris-Kawa Thanks.Solved!!!.Love you~