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:
#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();
}
#include <QApplication>
#include <QSvgRenderer>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsSvgItem>
#include <QBrush>
int main(int argc, char **argv) {
QApplication app(argc, argv);
// Create a renderer for this svg file
QSvgRenderer *svgRend = new QSvgRenderer(QLatin1String("test.svg"));
// Create a scene where set things
QGraphicsScene scene;
// Use a custom brush for the background
QBrush bgBrush(QColor(32, 32, 32), Qt::SolidPattern);
scene.setBackgroundBrush(bgBrush);
// Create svg item for the scene
QGraphicsSvgItem *svg = new QGraphicsSvgItem();
svg->setSharedRenderer(svgRend);
svg->setElementId(QLatin1String("shape"));
// Add the item to the scene
scene.addItem(svg);
// Initialize the view
QGraphicsView view(&scene);
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
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
svg->rotate(5.0);
svg->rotate(5.0);
To copy to clipboard, switch view to plain text mode
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
Bookmarks