Hi tim,<br>
Here is the code <br>
<br>
// QGIS Includes<br>
// Qt Includes<br>
// Std Includes<br>
<br>
int main(int argc, char ** argv) <br>
{<br>
// Start the Application<br>
QgsApplication app(argc, argv, true);<br>
<br>
QString myPluginsDir = "...../lib/qgis";
<br>
QString myLayerPath1 = ".............................
<div id="mb_2">.......shp";<br> QString myLayerBaseName1 = "....................shp";<br> QString myProviderName = "ogr";<br> QgsSymbol* symbol;
<br> QColor* color;<br> <br> <br> color = new QColor(255,0,0,255);<br> <br> symbol = new QgsSymbol(color->rgb());<br> <br> // Instantiate Provider Registry<br> QgsProviderRegistry::instance(myPluginsDir);
<br> QgsVectorLayer * mypLayer = new QgsVectorLayer(myLayerPath1, myLayerBaseName1, myProviderName);<br><br> //get the field list associated with the layer<br>std::vector<QgsField> myFields=mypLayer->fields();
<br> QgsUniqueValueRenderer *mypRenderer=new QgsUniqueValueRenderer(mypLayer->vectorType());<br> <br> mypRenderer->setClassificationField(5);<br> <br>symbol->setColor(Qt::red);<br> symbol->setFillColor(QColor(255,0,0));
<br> symbol->setLabel("HELLO");<br> symbol->setPointSize (5);<br> <br> <br> std::deque<QString> myLayerSet;<br> mypLayer->setRenderer(mypRenderer);<br>//mypRenderer->insertValue("point",symbol);
<br>if (mypLayer->isValid())<br> {<br> qDebug("Layer is valid");<br> }<br> else<br> {<br> qDebug("Layer is NOT valid");<br> }<br><br> // Add the Vector Layer to the Layer Registry<br>
<br>
QgsMapLayerRegistry::instance()->addMapLayer(mypLayer, TRUE);<br> // Add the Layer to the Layer Set<br> <br><br><br> myLayerSet.push_back(mypLayer->getLayerID());<br> mypLayer->setVisible(TRUE);<br><br>
<br><br> // Create the Map Canvas<br> QgsMapCanvas * mypMapCanvas = new QgsMapCanvas(0, 0);<br> mypMapCanvas->setExtent(mypLayer->extent());<br> // cbit qDebug(mypMapCanvas->extent().stringRep(2));<br> <br>
mypMapCanvas->enableAntiAliasing(true);
<br> mypMapCanvas->setCanvasColor(QColor(255, 255, 255));<br> mypMapCanvas->freeze(false);<br> // Set the Map Canvas Layer Set<br> mypMapCanvas->setLayerSet(myLayerSet);<br> mypMapCanvas->setVisible(true);
<br> mypMapCanvas->refresh();<br> // Start the Application Event Loop<br>//cout<<marker_symbol->picture().toStdString()<<endl;<br>app.exec();<br> //QgsMapCanvas myMapCanvas(0, 0);<br> QgsMapLayerRegistry::instance()->removeAllMapLayers();
<br>return 0;<br>}<br><br>I created symbol, but don't know how to add that to the unique value renderer.<br><br>Thanking you<br>cheers<br><span class="sg">satya</span></div>
<div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><span class="sg"></span><div><span class="e" id="q_11124feb1e6bcbac_2"><br><br><br><br>
<div><span class="gmail_quote">On 3/5/07, <b class="gmail_sendername">
Tim Sutton</b> <<a href="mailto:tim@linfiniti.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">tim@linfiniti.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi<br><br>How about posting code examples of what you have tried and we can try<br>to help you from there....<br><br>Regards<br><br>Tim<br><br>2007/3/5, satya satya <<a href="mailto:satya341@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
satya341@gmail.com
</a>>:<br>> Hello all,<br>>
I am trying to develop a simple application using QGis API.<br>> I have read all tutorials on QGis blog. I would like to use<br>> "QgsUniqueValueRenderer" in my application to display features in diff
<br>> colors. I tried that "QgsUniqueValueRenderer" , but no luck.<br>> could some body help me .<br>> cheers<br>> satya<br>><br>> _______________________________________________<br>> Qgis-developer mailing list
<br>> <a href="mailto:Qgis-developer@lists.qgis.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Qgis-developer@lists.qgis.org</a><br>> <a href="http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
</a><br>><br>><br><br><br>--<br>--<br>Tim Sutton<br><br>Visit <a href="http://qgis.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://qgis.org</a> for a great Open Source GIS<br>Home Page:
<a href="http://linfiniti.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://linfiniti.com</a><br>Skype: timlinux
<br>MSN: <a href="mailto:tim_bdworld@msn.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">tim_bdworld@msn.com</a><br>Yahoo: <a href="mailto:tim_bdworld@yahoo.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
tim_bdworld@yahoo.com</a><br>Jabber: timlinux<br>Irc: timlinux on #qgis at <a href="http://freenode.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
freenode.net</a><br></blockquote></div><br>
</span></div></blockquote></div><br>