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 Updated to NodeBB v4.3 + New Features

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.
  • MfabianM Offline
    MfabianM Offline
    Mfabian
    wrote on 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
    • kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by kshegunov
      #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
      • MfabianM Offline
        MfabianM Offline
        Mfabian
        wrote on last edited by Mfabian
        #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";
            [...]
        }
        
        kshegunovK 1 Reply Last reply
        0
        • MfabianM Mfabian

          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";
              [...]
          }
          
          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on 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

          • Login

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