Hi Martin, I implemented my own canvas item for SVG markers like you told me. But When I created a object of custom canvas item in main, it broke down. The error says 'This may be due to a corruption of the heap...', see more in error.jpg. I looked up for answers in exchange, which I found a similar topic here <http://gis.stackexchange.com/questions/81465/how-to-refresh-layers-independently/81470#81470> , in the topic Nathan did exactly what I did. I don't know why. <http://osgeo-org.1560.x6.nabble.com/file/n5161805/error.jpg> Here is my code: //main.cpp int main(int argc, char ** argv) { // Start the Application QgsApplication app(argc, argv, true);
QgsMapCanvas * mypMapCanvas = new QgsMapCanvas(); mypMapCanvas->setVisible(true); mypMapCanvas->refresh(); QString fileName = "D:\\qgis\\svg\\symbol\\poi_tower_communications.svg"; TFMapCanvasSvgItem mTFSvgItem(mypMapCanvas, fileName); mTFSvgItem.setPos(0, 0); return app.exec(); } // Custom canvas item class -TFMapCanvasSvgItem.h class TFMapCanvasSvgItem: public QgsMapCanvasItem { public: TFMapCanvasSvgItem(QgsMapCanvas* canvas, QString fileName = ""); ~TFMapCanvasSvgItem(); void paint(QPainter* painter); QRectF boundingRect() const; void setFilePath(const QString& file); QString filePath() const {return mFilePath;} private: QSvgRenderer mSvgRenderer; QString mFilePath; }; //TFMapCanvasSvgItem.cpp TFMapCanvasSvgItem::TFMapCanvasSvgItem(QgsMapCanvas* canvas, QString fileName): QgsMapCanvasItem(canvas), mSvgRenderer(fileName) { } TFMapCanvasSvgItem::~TFMapCanvasSvgItem() { } void TFMapCanvasSvgItem::paint(QPainter* painter) { if (!painter) { return; } QRectF viewBox = mSvgRenderer.viewBoxF(); if (viewBox.isValid()) { setPos(this->toCanvasCoordinates(QgsPoint(0.0, 0.0))); mSvgRenderer.render(painter, viewBox); } } QRectF TFMapCanvasSvgItem::boundingRect() const { QRectF viewBox = mSvgRenderer.viewBoxF(); qreal halfWeight = viewBox.width() / 2; qreal halfHeight = viewBox.height() / 2; return QRectF(-halfWeight, -halfHeight, viewBox.width(), viewBox.height()); } void TFMapCanvasSvgItem::setFilePath(const QString& file) { mFilePath = file; mSvgRenderer.load(mFilePath); } -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Is-QGIS-supports-dynamic-display-tp5155726p5161805.html Sent from the Quantum GIS - Developer mailing list archive at Nabble.com. _______________________________________________ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer