[Qgis-developer] How do I change the symbol and its size from a provider?

Ken Roser kroser at roser.us
Wed Jan 23 12:19:59 EST 2008

Sorry if I wasn't too clear.  Let me try to present the problem just a 
bit differently.

Let's say I'm using the delimited text plugin and provider, as is, in 
the source code, but I want to modify it so that the points are 
displayed as triangles instead of squares and at size 20 instead of the 
default.  These choices would be built into the software, i.e., not user 
selectable.  How would I do that?

Tim Sutton wrote:
> 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

More information about the Qgis-developer mailing list