[Qgis-developer] How do I change the symbol and its size from a
provider?
Tim Sutton
tim at linfiniti.com
Wed Jan 23 11:57:08 EST 2008
Hi Ken
I'm not sure that it makes sense to set symbology in your provider
itself so Im hoping you are trying to do it from some kind of add
layer gui, but you havent provided much information for me to know
whats really going on. That said here is how you can set the symbol on
a new vector layer instance programmatically:
1572 QgsSymbol * mypSymbol = new
QgsSymbol(mypVectorLayer->vectorType());
1573 QColor
myPresenceColor(mySettings.value("mapping/presenceColour",QColor(Qt::green).name()).toString());
1574 mypSymbol->setFillColor(myPresenceColor);
1575 mypSymbol->setColor(Qt::black); //outline
1576 mypSymbol->setPointSize(mySymbolSize);
1577 mypSymbol->setFillStyle(Qt::SolidPattern);
1578 QgsSingleSymbolRenderer *mypRenderer = new
QgsSingleSymbolRenderer(mypVectorLayer->vectorType());
1579 mypRenderer->addSymbol(mypSymbol);
1580 mypVectorLayer->setRenderer(mypRenderer);
The above is a single symbol renderer take from one of my cpp
projects. The same project also implements a unigue value renderer -
see the original source at http://tinyurl.com/3xystm for more info.
I hope that helped!
Regards
Tim
2008/1/23, Ken Roser <kroser at roser.us>:
> I'm writing a plugin/provider that's similar in functionality to the
> delimited text plug in. Things are working well, but I need to change
> the size, color and possibly the symbol itself when I add a point to the
> map. I've been unable to determine a method of doing so other than
> going to the symbology tab on the layer properties dialog. I want the
> change to happen automatically via the provider code. Can anyone help out?
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.qgis.org
> http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
>
--
Tim Sutton
QGIS Project Steering Committee Member - Release Manager
Visit http://qgis.org for a great open source GIS
openModeller Desktop Developer
Visit http://openModeller.sf.net for a great open source ecological
niche modelling tool
Home Page: http://tim.linfiniti.com
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
More information about the Qgis-developer
mailing list