如果我在64x64的(0,0)处绘制SVG项,则实际显示的SVG项来自于65x65的(-0.5,-0.5)。我通过在SVG项目后面绘制边界框来测量这一点。并且SVG项目在QGraphicsScene上以半个单位从四边伸出。
我可以移除这个效果吗?我已将笔设置为NoPen。我可以缩小它,但这是非常不精确的(因为宽度和高度需要不同的缩放比例,这几乎是不可能的)。如何解决此问题?

如您所见,棕色框(SVG)突出在灰色区域(边界框)上。使用Inkscape确认边界框。
谢谢
发布于 2011-09-28 19:39:09
使用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));https://stackoverflow.com/questions/7544921
复制相似问题