If I draw an SVG item at (0, 0) with 64x64, the actual displayed SVG item is from (-0.5, -0.5) with 65x65. I measured this by drawing the boundingbox behind the SVG item. And the SVG item is sticking out at all sides by a half unit on the QGraphicsScene.
Can I remove this effect? I have set the pen to NoPen. I could 开发者_开发知识库scale it down, but that would be quite unprecise (since width and height need different scaling, which is hardly possible). How can I fix this issue?
As you can see, the brown boxes (SVG) stick out over the grey area (bounding box). The bounding box is confirmed with Inkscape.
Thanks
Found the solution using transform:
QSvgRenderer *test = new QSvgRenderer(QLatin1String("test.svg"));
QGraphicsSvgItem *item = new QGraphicsSvgItem();
item->setSharedRenderer(test);
addItem(item);
// the following transformation is required if you want the SVG to be exactly on the spot and as big as it should be
item->setTransform(QTransform(test->viewBoxF().width() / (test->viewBoxF().width() + 1.0), 0.0, 0.0, test->viewBoxF().height() / (test->viewBoxF().height() + 1.0), 0.5, 0.5));
精彩评论