I'm trying to find documentation regarding a signal or event when I click Minimize on a QMainWindow.
Basically, when I click Minimize, I want to know about it.
Any Advice?
Windows 7 64, Qt 5.
I'm trying to find documentation regarding a signal or event when I click Minimize on a QMainWindow.
Basically, when I click Minimize, I want to know about it.
Any Advice?
Windows 7 64, Qt 5.
QWidget::changeEvent() seemingly notifies changes in the window state (event type QEvent::WindowStateChange). See the docs for details.
Henry Blue Heeler (3rd July 2014)
You should receive QWidget::hideEvent() and showEvent() calls on minimise/restore.
Henry Blue Heeler (11th July 2014)
Thanks Chris, I'll need to try hideEvent() and showEvent().
changeEvent() worked great for my purposes, e.g.
Qt Code:
{ event->accept(); { if( windowState() == Qt::WindowMinimized ) { doSomething(this); } else if( windowState() == Qt::WindowNoState ) { doSomethingElse(this); } } }To copy to clipboard, switch view to plain text mode
hideEvent() and showEvent() are less specific than QEvent::WindowStateChange; they are called when a widget is hidden/shown for any reason, not limited to a window being minimized/restored/maximized.
Your code probably overrides more behaviour than you wish. If I were you, I would try this instead:
That code does interfere with QMainWindow's event handling; it only does something afterwards (which is what you seem to need here).Qt Code:
{ { if( windowState() == Qt::WindowMinimized ) { doSomething(this); } else if( windowState() == Qt::WindowNoState ) { doSomethingElse(this); } } }To copy to clipboard, switch view to plain text mode
Bookmarks