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

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 6.1.2, 6.2.2
    • GUI: High-DPI
    • None
    • 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

        1. Mask.gif
          321 kB
          Damian Lettie

        Issue Links

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

          Activity

            People

              vgt Eirik Aavitsland
              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