Details
-
Type:
Bug
-
Status: Reported
-
Priority:
P2: Important
-
Resolution: Unresolved
-
Affects Version/s: 6.1.2, 6.2.2
-
Fix Version/s: None
-
Component/s: GUI: High-DPI
-
Labels:None
-
Platform/s:
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(); }