[Qgis-user] SVG Issues in QGIS API

Tendfly niu niubob at hotmail.com
Wed Oct 15 06:29:56 PDT 2014


Hi all,

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));

}    

 

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.

Any advice appreciated!

Regards,

 

Bob

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20141015/07011d28/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1.PNG
Type: image/png
Size: 28538 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20141015/07011d28/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2.PNG
Type: image/png
Size: 25581 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20141015/07011d28/attachment-0001.png>


More information about the Qgis-user mailing list