Hi,<div>I have a Qgis plugin C++. I have subclassing QgisVertexMarker because I wont show on my application my custom icon.</div><div>This is my code:</div><div><br></div><div>/////////////////HEADER FILE</div><div><br></div>
<div><div>#ifndef HLVERTEXMARKER_H</div><div>#define HLVERTEXMARKER_H</div><div><br></div><div>#include <qgsvertexmarker.h></div><div><br></div><div>class GUI_EXPORT hlVertexMarker : public QgsVertexMarker</div><div>
{</div><div><br></div><div>public:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//! Icons</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>enum IconType</div>
<div> {</div><div> ICON_NONE,</div><div> ICON_CROSS,</div><div> ICON_X,</div><div> ICON_BOX,</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> ICON_CUSTOM</div><div> };</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>hlVertexMarker(QgsMapCanvas* mapCanvas);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>void paint(QPainter* p);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>void setIconFileName(QString xFileName);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>QRectF boundingRect() const;</div><div><br>
</div><div>private:</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>QString m_xFileName;</div><div>};</div><div><br></div><div>#endif</div></div><div><br></div><div>//////////////////////////////////CPP File</div>
<div><br></div><div><br></div><div><div>#include <QPainter></div><div><br></div><div>hlVertexMarker::hlVertexMarker(QgsMapCanvas *mapCanvas) : QgsVertexMarker(mapCanvas)</div><div>{</div><div>}</div><div><br></div><div>
void hlVertexMarker::setIconFileName(QString xFileName)</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>m_xFileName = xFileName;</div><div>}</div><div><br></div><div><br></div><div>void hlVertexMarker::paint(QPainter *p)</div>
<div>{</div><div> // setIconSize(48);</div><div> qreal s = ( mIconSize - 1 ) / 2;</div><div><br></div><div> QPen pen( mColor );</div><div> pen.setWidth( mPenWidth );</div><div> p->setPen( pen );</div><div><br></div>
<div> switch ( mIconType )</div><div> {</div><div> case ICON_NONE:</div><div> break;</div><div><br></div><div> case ICON_CROSS:</div><div> p->drawLine( QLineF( -s, 0, s, 0 ) );</div><div> p->drawLine( QLineF( 0, -s, 0, s ) );</div>
<div> break;</div><div><br></div><div> case ICON_X:</div><div> p->drawLine( QLineF( -s, -s, s, s ) );</div><div> p->drawLine( QLineF( -s, s, s, -s ) );</div><div> break;</div><div><br></div><div>
case ICON_BOX:</div><div> p->drawLine( QLineF( -s, -s, s, -s ) );</div><div> p->drawLine( QLineF( s, -s, s, s ) );</div><div> p->drawLine( QLineF( s, s, -s, s ) );</div><div> p->drawLine( QLineF( -s, s, -s, -s ) );</div>
<div> break;</div><div><br></div><div> case ICON_CUSTOM:</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> QPixmap pixmap(QSize(48,48));</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> pixmap.load(m_xFileName);</div>
<div> p->drawPixmap(0, 0,pixmap);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> break;</div><div> }</div><div>}</div><div><br></div><div>QRectF hlVertexMarker::boundingRect() const</div>
<div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//Bounding Box</div><div> qreal s = qreal(mIconSize) / 2.0;</div><div> return QRectF( -2.0*s, -2.0*s, 2.0*s, 2.0*s );</div><div>}</div></div>
<div><br></div><div><br></div><div>Whe on my plugin I use my custom VertexMarke Qgis after few second crash. If I use standard QgisVertexMarker the program work correctly.</div><div><br></div><div>Can anyone help me please??</div>
<div><br></div><div>bye</div>