[Qgis-developer] how to add labels to PluginLayer? - please help!
Mikhail Tchernychev
misha at mail.geometrics.com
Mon Oct 14 12:01:55 PDT 2013
Hi,
Apparently no one is to help me... I found it is not simply possible to put
labels at where I want on the plugin layer. Apparently no one is using
QGsLabel
anymore, and documentation is missing or obscure...
Qgis keeps crashing on me when I try to add label in python, which I
believe is a bug
anyway.
Regards,
Mikhail
Original post:
> Hi,
>
> I am trying to add labels to the plugin layer. What I use in draw()
> is:
>
> fields = QgsFields()
> fields.append(QgsField('0', QtCore.QVariant.String, 'string', 32))
> fields.append(QgsField('8', QtCore.QVariant.Double, 'double', 8))
> fields.append(QgsField('9', QtCore.QVariant.Double, 'double', 8))
>
> feat = QgsFeature(fields)
> label = QgsLabel(fields)
> feat.setAttribute('0','Test Text')
> feat.setAttribute('8', -8.66774)
> feat.setAttribute('9', 37.08391)
>
> label.renderLabel(renderContext, feat, False)
>
> - QGIS crashes (2.0.1, stock version, Linux)
>
> There is almost no doc on how to add labels to the layer
> I am trying to mimic field 'Text' 'XCoordinate' and 'YCoordinate'
> with '0', '8' and '9' based on enum LabelField
>
> Apparently also some change in the Api since 1.8, I was
> using GridPlugin from 1.8 as example, but something is different now.
>
> Could anyone shed some light on it?
>
> I am actually developing Lat/Lon grid plugin for QGIS, which I think
> very much needed.
>
> Thank you
> Mikhail
More information about the Qgis-developer
mailing list