I need to know when a window is restored or maximized. When this state-change happens, I need to take an action. I need to be careful however that this action only occurs once per state-change. I have the following code:
void TextArea
::changeEvent(QEvent* event
) {
if (event
->type
() == QEvent::WindowStateChange) {
if (static_cast<QWindowStateChangeEvent*>(event)->oldState() == windowState())
{
return;
}
if (isMaximized())
{
}
else
{
}
}
}
void TextArea::changeEvent(QEvent* event)
{
if (event->type() == QEvent::WindowStateChange)
{
if (static_cast<QWindowStateChangeEvent*>(event)->oldState() == windowState())
{
return;
}
if (isMaximized())
{
}
else
{
}
}
QWidget::changeEvent(event);
}
To copy to clipboard, switch view to plain text mode
Even with the preceding code, the action is firing twice with the old-state being 0 and new state being 2. Is there any way to ensure that this fires only once?
Bookmarks