<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        font-size:10.5pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:SimSun;}
code
        {mso-style-priority:99;
        font-family:SimSun;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML \9884\8BBE\683C\5F0F Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:SimSun;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        text-indent:21.0pt;
        font-size:10.5pt;
        font-family:"Calibri","sans-serif";}
span.HTMLChar
        {mso-style-name:"HTML \9884\8BBE\683C\5F0F Char";
        mso-style-priority:99;
        mso-style-link:"HTML \9884\8BBE\683C\5F0F";
        font-family:SimSun;}
span.EmailStyle22
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle23
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle24
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=ZH-CN link=blue vlink=purple style='text-justify-trim:punctuation'><div class=WordSection1><p class=MsoNormal align=left style='margin-bottom:12.0pt;text-align:left;line-height:13.5pt;vertical-align:baseline'><span lang=EN-US style='font-family:"Helvetica","sans-serif";color:#333333'>Hi all,<o:p></o:p></span></p><p class=MsoNormal align=left style='margin-bottom:12.0pt;text-align:left;line-height:13.5pt;vertical-align:baseline'><span lang=EN-US style='font-family:"Helvetica","sans-serif";color:#333333'>I'm using QGIS-2.4.0 to developing an application.<o:p></o:p></span></p><p class=MsoNormal align=left style='margin-bottom:12.0pt;text-align:left;line-height:13.5pt;vertical-align:baseline'><span lang=EN-US style='font-family:"Helvetica","sans-serif";color:#333333'>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.<o:p></o:p></span></p><p class=MsoNormal align=left style='margin-bottom:12.0pt;text-align:left;line-height:13.5pt;vertical-align:baseline'><span lang=EN-US style='font-family:"Helvetica","sans-serif";color:#333333'>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.<o:p></o:p></span></p><p class=MsoNormal align=left style='margin-bottom:12.0pt;text-align:left;line-height:13.5pt;vertical-align:baseline'><span lang=EN-US style='font-family:"Helvetica","sans-serif";color:#333333'>I don't know why, Can anyone help me? Here is my code to rewrite the function from QgsMapCanvasItem:<o:p></o:p></span></p><p class=MsoNormal align=left style='text-align:left;line-height:13.5pt;background:#EEEEEE;vertical-align:baseline'><span lang=EN-US style='font-size:9.0pt;font-family:Consolas;color:#222222;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>void TFMapCanvasSvgItem::paint(QPainter* painter)<o:p></o:p></span></p><p class=MsoNormal align=left style='text-align:left;line-height:13.5pt;background:#EEEEEE;vertical-align:baseline'><span lang=EN-US style='font-size:9.0pt;font-family:Consolas;color:#222222;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>{        <o:p></o:p></span></p><p class=MsoNormal align=left style='text-align:left;line-height:13.5pt;background:#EEEEEE;vertical-align:baseline'><span lang=EN-US style='font-size:9.0pt;font-family:Consolas;color:#222222;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>  if (!painter)<o:p></o:p></span></p><p class=MsoNormal align=left style='text-align:left;line-height:13.5pt;background:#EEEEEE;vertical-align:baseline'><span lang=EN-US style='font-size:9.0pt;font-family:Consolas;color:#222222;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>  {<o:p></o:p></span></p><p class=MsoNormal align=left style='text-align:left;line-height:13.5pt;background:#EEEEEE;vertical-align:baseline'><span lang=EN-US style='font-size:9.0pt;font-family:Consolas;color:#222222;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>    return;<o:p></o:p></span></p><p class=MsoNormal align=left style='text-align:left;line-height:13.5pt;background:#EEEEEE;vertical-align:baseline'><span lang=EN-US style='font-size:9.0pt;font-family:Consolas;color:#222222;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>  }<o:p></o:p></span></p><p class=MsoNormal align=left style='text-align:left;line-height:13.5pt;background:#EEEEEE;vertical-align:baseline'><span lang=EN-US style='font-size:9.0pt;font-family:Consolas;color:#222222;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>  QImage svgImage(50, 40, QImage::Format_ARGB32);<o:p></o:p></span></p><p class=MsoNormal align=left style='text-align:left;line-height:13.5pt;background:#EEEEEE;vertical-align:baseline'><span lang=EN-US style='font-size:9.0pt;font-family:Consolas;color:#222222;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>  QPainter imagePainter(&svgImage);<o:p></o:p></span></p><p class=MsoNormal align=left style='text-align:left;line-height:13.5pt;background:#EEEEEE;vertical-align:baseline'><span lang=EN-US style='font-size:9.0pt;font-family:Consolas;color:#222222;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>  mSvgRenderer.render(&imagePainter);<o:p></o:p></span></p><p class=MsoNormal align=left style='text-align:left;line-height:13.5pt;background:#EEEEEE;vertical-align:baseline'><span lang=EN-US style='font-size:9.0pt;font-family:Consolas;color:#222222;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>  painter->drawImage(QRect(0, 0, 100, 80), svgImage, QRect(0, 0, 100, 80));<o:p></o:p></span></p><p class=MsoNormal align=left style='text-align:left;line-height:13.5pt;background:#EEEEEE;vertical-align:baseline'><span lang=EN-US style='font-size:9.0pt;font-family:Consolas;color:#222222;border:none windowtext 1.0pt;padding:0cm;background:#EEEEEE'>}    <o:p></o:p></span></p><p class=MsoNormal align=left style='margin-bottom:12.0pt;text-align:left;line-height:13.5pt;vertical-align:baseline'><span lang=EN-US style='font-family:"Helvetica","sans-serif";color:#333333'><o:p> </o:p></span></p><p class=MsoNormal align=left style='margin-bottom:12.0pt;text-align:left;line-height:13.5pt;vertical-align:baseline'><span lang=EN-US style='font-family:"Helvetica","sans-serif";color:#333333'>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.<o:p></o:p></span></p><p class=MsoNormal align=left style='margin-bottom:12.0pt;text-align:left;line-height:13.5pt;vertical-align:baseline'><span lang=EN-US style='font-family:"Helvetica","sans-serif";color:#333333'>Any advice appreciated!<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:14.0pt'>Regards,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:14.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:14.0pt'>Bob<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div></body></html>