Disable minimizing of application
-
Hello,
I'd like to prevent my application to be minimized at any time without it staying on top. Right now I got the following flags:setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::Tool)
If I click "Show Desktop" on my Windows system in the toolbar, it minimizes all applications, which should not be true for my application.
Qt::WindowStaysOnTopHint
prevents the minimizing, but will keep my application on top all the time, which is undesired as well (I want other applications to be able to overlay it).Qt::WindowStaysOnBottomHint
does not prevent the minimizing and both combined obviously doesn't work.
Is there any hint (or other function) to do what I want or do I need to intercept the minimize-event and maximize my application manually again? -
Hello,
Have you tried intercepting the hide event, or even better to try and monitor the state changes? Something like this:void MyWidget::changeEvent(QEvent * event) { switch (event->type()) { case QEvent::WindowStateChange: setWindowState(reinterpret_cast<QWindowStateChangeEvent *>(event)->oldState()); event->accept(); break; default: QWidget::changeEvent(event); } }
Kind regards.
-
I've tried this just now and it leads to the same behaviour - using the "Show Desktop" feature of windows 7 toolbar minimizes the widget. I've also tried the following code:
void QTAnimeTool::changeEvent(QEvent* event) { switch (event->type()) { case QEvent::WindowStateChange: qDebug() << "Event"; event->accept(); break; default: QWidget::changeEvent(event); } }
Interestingly this never gives any output, which leaves me a bit confused what exactly Windows does to the applications if it doesn't change their state. Microsofts webpage states that the applications are minimized, but towards the test this seems not to be the case (http://windows.microsoft.com/en-us/windows/minimize-open-windows-view-desktop#1TC=windows-7). So far the only thing I found to prevent this behaviour is the aforementioned
Qt::WindowStaysOnTopHint
. Since it is probably relevant now, I'm using Windows 7 (x64) with Qt 5.5.Edit: As a matter of fact, absolutely no changeEvent is triggered. This gives no output on show desktop button click either:
void QTAnimeTool::changeEvent(QEvent* event) { qDebug() << "Event"; [...] }
-
I've tried this just now and it leads to the same behaviour - using the "Show Desktop" feature of windows 7 toolbar minimizes the widget. I've also tried the following code:
void QTAnimeTool::changeEvent(QEvent* event) { switch (event->type()) { case QEvent::WindowStateChange: qDebug() << "Event"; event->accept(); break; default: QWidget::changeEvent(event); } }
Interestingly this never gives any output, which leaves me a bit confused what exactly Windows does to the applications if it doesn't change their state. Microsofts webpage states that the applications are minimized, but towards the test this seems not to be the case (http://windows.microsoft.com/en-us/windows/minimize-open-windows-view-desktop#1TC=windows-7). So far the only thing I found to prevent this behaviour is the aforementioned
Qt::WindowStaysOnTopHint
. Since it is probably relevant now, I'm using Windows 7 (x64) with Qt 5.5.Edit: As a matter of fact, absolutely no changeEvent is triggered. This gives no output on show desktop button click either:
void QTAnimeTool::changeEvent(QEvent* event) { qDebug() << "Event"; [...] }
@Mfabian
Hello,
Sadly I'm not sure what the problem might be exactly.
It is possible that Windows, doesn't actually minimize the applications' windows when the "Show desktop" is clicked (contrary to what MSDN claims) but instead may just send everything behind the desktop, so then you'd really have no minimize event to capture, but this is pure speculation.Kind regards.