Border cutting with QGraphicsSvgItem
Hi there,
Today I was enjoying with Graphics View and SVG. I'm not expert with this framework, so maybe I messed up something :)
Here's the problem:
i setup a graphic view for svg, with svg renderer and item, but I noticed that - leaving everything untransformed - the edges of my svg shape are cutted off:
http://www.ale-re.net/images/softwares/border-cut.png
the original file was made with inkscape, this one:
http://www.ale-re.net/images/softwares/test.svg
The code is this:
Code:
#include <QApplication>
#include <QSvgRenderer>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsSvgItem>
#include <QBrush>
int main(int argc, char **argv) {
// Create a renderer for this svg file
// Create a scene where set things
// Use a custom brush for the background
scene.setBackgroundBrush(bgBrush);
// Create svg item for the scene
svg->setSharedRenderer(svgRend);
// Add the item to the scene
scene.addItem(svg);
// Initialize the view
view.show();
return app.exec();
}
I tried to translate/scale/rotate the item - if i'm not wrong, these should affect the item matrix, so the item only would change - but no results: the borders still seems cutted.
If you try to add
you can notice that borders are still cutted... It seems that bounding box is calculated without considering borders, so they are cutted.
Any idea?
Thanks very much!
p.s. well, as you can also notice, there is also an issue with text, which isn't put on multi-lines, but this is another issue :)
Re: Border cutting with QGraphicsSvgItem
How about if you resize the item with QGraphicsItem::setSize() ?
Is the ID passed to setElementId the root SVG element?
Re: Border cutting with QGraphicsSvgItem
:confused: I don't have QGraphicsItem::setSize() - using 4.2.3
main.cpp:22: error: 'class QGraphicsSvgItem' has no member named 'setSize'
and i didn't find it even in the documentation (even tough it says "
Size of the item can be set via the setSize() method or via direct manipulation of the items transformation matrix.", in http://doc.trolltech.com/4.2/qgraphicssvgitem.html)
Mh, actually the ID is the only element in the scene, but it isn't the root itself.
Changing it to element layer1 (parent of my object) doesn't change anything. Changing it to the svg element - root of the document - don't display anything.
Anyway, one should be able to select single element by id, so it shouldn't require to knowing things about its parents.
Thanks :)