I'm using QGIS-2.4.0 to developing an application.
I created my own custom MapCanvasItem for showing SVG. It is great to load a SVG from symbol library that QGIS provides(such as d:\QGIS Chugiak\apps\qgis\svg\symbol\poi_cave.svg), or a SVG file that QGIS Composer exports.
But when I created a SVG using Adobe Illustrator or Inkscape on my own, the application broke down to loading a SVG. I tested the SVG file created by Illustrator/Inkscape, it is well to display in QT project when I create a class Inheritanced from QgraphicsItem.
I don't know why, Can anyone help me? Here is my code to rewrite the function from QgsMapCanvasItem:
void TFMapCanvasSvgItem::paint(QPainter* painter)
{
if (!painter)
{
return;
}
QImage svgImage(50, 40, QImage::Format_ARGB32);
QPainter imagePainter(&svgImage);
mSvgRenderer.render(&imagePainter);
painter->drawImage(QRect(0, 0, 100, 80), svgImage, QRect(0, 0, 100, 80));
}
EDIT more:
The SVG symbol created by Illustrator/Inkscape couldn't be used in QGIS API application, but could be used in QGIS release software(such as Symbol selector, SVG annotation), as showed in 1.PNG, 2.PNG.
1.PNG
2.PNG