Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Disable minimizing of application
Forum Update on Tuesday, May 27th 2025

Disable minimizing of application

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 3.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mfabian
    wrote on 7 Mar 2016, 16:29 last edited by
    #1

    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?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 7 Mar 2016, 17:08 last edited by kshegunov 3 Jul 2016, 17:09
      #2

      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.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mfabian
        wrote on 7 Mar 2016, 20:37 last edited by Mfabian 3 Jul 2016, 20:41
        #3

        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";
            [...]
        }
        
        K 1 Reply Last reply 9 Mar 2016, 22:56
        0
        • M Mfabian
          7 Mar 2016, 20:37

          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";
              [...]
          }
          
          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 9 Mar 2016, 22:56 last edited by
          #4

          @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.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0

          1/4

          7 Mar 2016, 16:29

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved