QGraphicsView unprecise painting with raster engine
-
I have a QGraphicsView with multiple QGraphicsItems. The items draw a QPixmap into the boundingRect of the item and a black line on the border of the boundingRect. If I use the opengl painting engine the border is exactly where the image is painted. With raster engine there is (depending on the size of the graphics item) space between the drawn border and the drawn image. It looks like the sizes are calculated as integers and not as floats. Is there an option to set or a workaround for this painting errors ?
-
I'am zooming the viewport and the drawn rect should be drawn everytime with the same width in every zoom level. This item can be moved and resized, the inaccurate painting is only done in some zoom - size relations.
@
// draw the pixmap
painter->drawPixmap(dataItem()->rect(), pixmap)painter->setPen(QPen(Qt::black, 1.0, Qt::DashLine));
// reset the transformation
QTransform t(painter->transform());
painter->resetTransform();
// get the rect to draw without transformation
QPolygonF selectedPolygon = t.map(selectedRect);
painter->drawPolygon(selectedPolygon);// draw some other untransformed stuff
...
@I thought it is some kind of rounding problem, but with opengl it is exactly this code and it works.
This is how it looks
!http://img844.imageshack.us/img844/9009/bildschirmfoto20100720u.png(example)! -
I have a workaround for raster engine drawing of black rect with a small white border and deactivated Antialiasing.
@
qreal borderWidth = 1.0;
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::white);
painter->drawRects(rect);
painter->setBrush(Qt::black);
painter->drawRects(rect.adjusted(borderWidth, borderWidth, -borderWidth, -borderWidth));
@