PDA

View Full Version : VisualStudio plugin needs to know when app was minimized to tray



nnzz
4th November 2015, 15:24
Hi, I'm new to QT
I'm writing a VisualStudio addon which needs to know when app was minimized to tray
I have a class which inherits QApplication, in the notify() method I catch the QEvent::WindowStateChange
but I don't know how to distinguish between minimized and maximized events

d_stranz
4th November 2015, 22:13
You need to implement QWidget::changeEvent() for your widget, and when the event type is QEvent::WindowStateChange you need to cast the QEvent pointer to QWindowStateChangeEvent. Once you have that, you can call the QWindowStateChangeEvent::oldState() method, which will tell you what the state was *before* it changed.

You can also call QWidget::windowState() in the event handler to get the *current* state.