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

Garbage white lines using QPainter::fillRect() with QWidget::setMask(..., QRegion::Ellipse) at 175% DPI

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Duplicate
    • Affects Version/s: 6.1.2, 6.2.2
    • Fix Version/s: None
    • Component/s: GUI: High-DPI
    • Labels:
      None
    • Platform/s:
      Windows

      Description

      Running the below code on Windows at 175% DPI, white horizontal lines come and go at different positions as I resize the window:

      The problem only happens at 175% DPI, not 100% or 150%.
      The problem only happens with an elliptical mask, not a rectangular one.

      Tested Qt v6.2.2 and v6.1.2.
      Building in Qt Creator v6.0.1.
      Microsoft Visual Studio v16.11.7 is installed.
      Windows 10 v21H1.

       


      test.pro:

      QT += core gui widgets
      
      CONFIG += c++11
      
      SOURCES += \
          main.cpp \
          mainwindow.cpp
      
      HEADERS += \
          mainwindow.h
      

      mainwindow.h:

      #pragma once
      
      #include <QMainWindow>
      
      class TestWidget : public QWidget
      {
          Q_OBJECT
      protected:
          void resizeEvent(QResizeEvent *event) override;
          void paintEvent(QPaintEvent *event) override;
      };
      
      class MainWindow : public QMainWindow
      {
          Q_OBJECT
      public:
          MainWindow(QWidget *parent = nullptr);
      };
      

      mainwindow.cpp:

      #include "mainwindow.h"
      #include <QPainter>
      #include <QVBoxLayout>
      
      void TestWidget::resizeEvent(QResizeEvent *event)
      {
          setMask(QRegion(rect(), QRegion::Ellipse));
      }
      
      void TestWidget::paintEvent(QPaintEvent *event)
      {
          QPainter painter(this);
          painter.fillRect(rect(), Qt::blue);
      }
      
      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
      {
          auto *layout = new QVBoxLayout;
          layout->addWidget(new TestWidget);
          auto *centralWidget = new QWidget;
          centralWidget->setLayout(layout);
          setCentralWidget(centralWidget);
      }
      

      main.cpp:

      #include "mainwindow.h"
      #include <QApplication>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          MainWindow w;
          w.show();
          return a.exec();
      }
      

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              vgt Eirik Aavitsland
              Reporter:
              lidl Damian Lettie
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes