Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
4.8.4, 5.0.0 Beta 2
-
None
-
Windows 7
Description
When a QRect with negative width and/or height is drawn with QPainter::drawRect(const QRectF &rect), the pen is drawn in the incorrect place. See the following code for an example. It draws one QRect with negative width/height on the left, and one normalized QRect on the right. The left one's brush is drawn correctly, but the pen puts the top left corner one pixel down and to the right. The attached picture is an enlargement of the result so that you can clearly see the result.
// Qt 5 code #include <QtGui> #include <QtWidgets> class PainterWidget : public QWidget { void paintEvent(QPaintEvent *) { QPainter painter(this); painter.setBrush(QBrush(Qt::red, Qt::SolidPattern)); QRect rectLeft(100, 100, -50, -50); QRect rectRight(200, 100, -50, -50); // same width/height as rectRight painter.drawRect(rectLeft); painter.drawRect(rectRight.normalized()); } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); PainterWidget widget; widget.show(); return a.exec(); }
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-28851 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
138202,2 | Fixed pen painting with negative width/height when using QRect/QRectF | 5.6 | qt/qtbase | Status: ABANDONED | -2 | 0 |
150106,1 | Normalize QRects the way QPainter expects them. | 5.7 | qt/qtbase | Status: ABANDONED | 0 | 0 |
173060,3 | Normalize QRects the way QPainter expects them | dev | qt/qtbase | Status: MERGED | +2 | 0 |