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

Maximized frameless window painting wrong view region with Qt::FramelessWindowHint and Windows api WS_THICKFRAME

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • None
    • 6.5.1, 6.6.1
    • None
    • Qt/PyQt > 6.4.2
      Windows 10 22H2
    • Windows
    • 5f7b4c045 (dev), 2b18f6c7b (6.7), 19a473137 (6.6), 27c8d61e9 (tqtc/lts-6.5)

    Description

      When draw FramelessWindow using Qt6.6.1 with this method:

      1. Set window flags through setWindowFlags(this->windowFlags() | Qt::Window | Qt::FramelessWindowHint)
      2. Using windows api GetWindowLong and SetWindowLong add GWL_STYLE with WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | CS_DBLCLKS flags
      3. Using native event WM_NCCALCSIZE to tell windows client rect

      This method works fine with Qt <= 6.4.2, but in Qt6.6.1, the right and bottom exceed the drawable range.

      This is a simple example window create with Qt6.4.2, it's correct

      And this is the effect of the same code on QT 6.6.1, with both the right and bottom exceeding the drawable area.

      When using the overloaded function changeEvent to print the geometry of the widget,it will get quiet different answer between these two version

      Test Code:

      void MainWindow::changeEvent(QEvent *e)
      {
          if (e->type() == QEvent::WindowStateChange) {
              qDebug() << "Qt version =" << QT_VERSION_STR << "," << this->geometry();
          }
      } 

      With click custom maximize button twice, the result is:

      With Qt 6.4.2

      Qt version = 6.4.2 , QRect(515,210 709x519)
      Qt version = 6.4.2 , QRect(0,0 1739x939)

      With Qt 6.6.1

      Qt version = 6.6.1 , QRect(515,210 709x519)
      Qt version = 6.6.1 , QRect(-7,-7 1753x954)

      This result can be reproduced both on Qt Cpp version and PyQt

       

       

      Attachments

        1. bisect_result.log
          0.7 kB
          alex alex
        2. bisect.log
          2 kB
          alex alex
        3. image-2023-12-17-17-40-13-941.png
          124 kB
          alex alex
        4. image-2023-12-17-17-40-17-212.png
          126 kB
          alex alex
        5. TEST6.4.2.png
          111 kB
          alex alex
        6. TEST6.6.1.png
          110 kB
          alex alex
        7. testFrameless.zip
          7 kB
          alex alex
        For Gerrit Dashboard: QTBUG-120196
        # Subject Branch Project Status CR V

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            alexzh alex alex
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews