Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-139330

When switching from fullscreen to maximized, windows are briefly displayed as 'normal' windows.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.7.3, 6.9.1
    • None

      I wrote a minimal example where a simple window can be toggled between fullscreen and how it was shown before.

      This works in general, but when the window is maximized and then set to fullscreen the window is behaving irritating by switching to "normal" for a moment and then the animation to maximized is started.

      FullscreenableWidget.hpp

      #include <QWidget>
      #include <QShortcut>
      
      class FullscreenableWidget : public QWidget
      {
      public:
          FullscreenableWidget()
          {
             const auto stdFS = new QShortcut{ QKeySequence::FullScreen, this };
             connect(stdFS, &QShortcut::activated, this, &FullscreenableWidget::toggleFullScreen);
          }
      
      private slots:
          void toggleFullScreen()
          {
             if(!isFullScreen())
             {
                m_prevState = windowState();
                if(!isMaximized())
                {
                   m_prevGeometry = geometry();
                }
                showFullScreen();
             } else {
                if(m_prevState.testFlag(Qt::WindowMaximized))
                {
                   showMaximized();
                }
                else if(m_prevGeometry.isValid())
                {
                   showNormal();
                   setGeometry(m_prevGeometry);
                }
             }
          }
      
          Qt::WindowStates m_prevState{ Qt::WindowNoState };
          QRect m_prevGeometry;
      }; 

      main.cpp

      #include <QApplication>
      #include "FullscreenableWidget.hpp"
      
      int main(int argc, char* argv[])
      {
          QApplication app(argc, argv);
          FullscreenableWidget window;
          window.show();
      
          return app.exec();
      } 

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            dtr_basler David Röhling
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes