QPainter zero point bug
Unsolved
General and Desktop
-
So here is the code
void SButton::paintEvent(QPaintEvent* event) { QPushButton::paintEvent(event); if (m_strikeout == true) { QPainter painter; painter.begin(this); painter.setPen(QColor(0, 0, 0)); QRectF br = rect(); br.adjust(m_margin_left, m_margin_top, -m_margin_right, -m_margin_bottom - m_o_label->size().height()); painter.drawRect(br); painter.end(); } }
br is 19;19;341;251
here screens from 2 different PCs with SAME version of windows/directX ..., but with different hardware (processor and video)
First:
Second:
Upper left point is 0;0 point of my SButton widget
How does it works? i'm very confused
I try change Qrect to QrectF, draw lines and other stuff, on second PC i always got +1px at height
-
kind of shooting in the dark here, but remember that the painter coordinate system can be scaled, rotated, and new origin set. Try explicitly defining the coordinate system...Also, if your coordinates are floating point then you have to deal with floating point roundoff error.