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)
- // reset the transformation
- QTransform t(painter->transform());
- // get the rect to draw without transformation
- QPolygonF selectedPolygon = t.map(selectedRect);
- // 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
I have a workaround for raster engine drawing of black rect with a small white border and deactivated Antialiasing.