Hi Marco,<br>
I uncommented <span style="font-weight: bold;">//mypRenderer-&gt;insertValue(&quot;point&quot;,symbol); </span>,
I changed &quot;POINT&quot; to &quot;Dmg_zip&quot; which is one of the attributes of my
shape file. Unfortunately it displayed nothing. Do i need to iterate
all the points in the shaped file??<br>
Thaking you<br>
regards<br>
satya<br>
<br><br><div><span class="gmail_quote">On 3/7/07, <b class="gmail_sendername">Marco Hugentobler</b> &lt;<a href="mailto:marco.hugentobler@karto.baug.ethz.ch">marco.hugentobler@karto.baug.ethz.ch</a>&gt; 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 Satya,<br><br>Just use the Method QgsUniqueValueRenderer::insertValue(QString name,<br>QgsSymbol* symbol). The first parameter is the attribute value for which the<br>symbol is valid, the second a pointer to your symbol (ok, &#39;name&#39; is a
<br>misleading name for the parameter...)<br><br>In the code below, there is the outcommented line<br>//mypRenderer-&gt;insertValue(&quot;point&quot;,symbol);<br>I suppose &quot;point&quot; is not the attribute value for which you want the symbol to
<br>be applied? Try to replace it with the attribute value and see if it works.<br><br>If you want the symbol to be valid for all features, then you can use<br>QgsSingleSymbolRenderer, method<br>QgsSingleSymbolRenderer::addSymbol(QgsSymbol*)
<br><br>Best regards,<br>Marco<br><br>Am Mittwoch, 7. März 2007 15:38 schrieb satya satya:<br>&gt; Hi tim,<br>&gt; Here is the code<br>&gt;<br>&gt; // QGIS Includes<br>&gt; // Qt Includes<br>&gt; // Std Includes<br>&gt;<br>
&gt; int main(int argc, char ** argv)<br>&gt; {<br>&gt;&nbsp;&nbsp; // Start the Application<br>&gt;&nbsp;&nbsp; QgsApplication app(argc, argv, true);<br>&gt;<br>&gt;&nbsp;&nbsp; QString myPluginsDir&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &quot;...../lib/qgis&quot;;<br>&gt;&nbsp;&nbsp; QString myLayerPath1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = &quot;.............................
<br>&gt; .......shp&quot;; QString myLayerBaseName1&nbsp;&nbsp;&nbsp;&nbsp; = &quot;....................shp&quot;;<br>&gt;&nbsp;&nbsp; QString myProviderName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &quot;ogr&quot;;<br>&gt;&nbsp;&nbsp; QgsSymbol* symbol;<br>&gt;&nbsp;&nbsp; QColor* color;<br>&gt;<br>&gt;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; color = new QColor(255,0,0,255);<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; symbol = new QgsSymbol(color-&gt;rgb());<br>&gt;<br>&gt;&nbsp;&nbsp; // Instantiate Provider Registry<br>&gt;&nbsp;&nbsp; QgsProviderRegistry::instance(myPluginsDir);<br>&gt;&nbsp;&nbsp; QgsVectorLayer * mypLayer = new QgsVectorLayer(myLayerPath1,
<br>&gt; myLayerBaseName1, myProviderName);<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;//get the field list associated with the layer<br>&gt; std::vector&lt;QgsField&gt; myFields=mypLayer-&gt;fields();<br>&gt;&nbsp;&nbsp; QgsUniqueValueRenderer *mypRenderer=new
<br>&gt; QgsUniqueValueRenderer(mypLayer-&gt;vectorType());<br>&gt;<br>&gt;&nbsp;&nbsp; mypRenderer-&gt;setClassificationField(5);<br>&gt;<br>&gt; symbol-&gt;setColor(Qt::red);<br>&gt;&nbsp;&nbsp; symbol-&gt;setFillColor(QColor(255,0,0));<br>
&gt;&nbsp;&nbsp; symbol-&gt;setLabel(&quot;HELLO&quot;);<br>&gt;&nbsp;&nbsp; symbol-&gt;setPointSize (5);<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp; std::deque&lt;QString&gt; myLayerSet;<br>&gt;&nbsp;&nbsp; mypLayer-&gt;setRenderer(mypRenderer);<br>&gt; //mypRenderer-&gt;insertValue(&quot;point&quot;,symbol);
<br>&gt; if (mypLayer-&gt;isValid())<br>&gt;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; qDebug(&quot;Layer is valid&quot;);<br>&gt;&nbsp;&nbsp; }<br>&gt;&nbsp;&nbsp; else<br>&gt;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; qDebug(&quot;Layer is NOT valid&quot;);<br>&gt;&nbsp;&nbsp; }<br>&gt;<br>&gt;&nbsp;&nbsp; // Add the Vector Layer to the Layer Registry
<br>&gt;<br>&gt;&nbsp;&nbsp; QgsMapLayerRegistry::instance()-&gt;addMapLayer(mypLayer, TRUE);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; // Add the Layer to the Layer Set<br>&gt;<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp; myLayerSet.push_back(mypLayer-&gt;getLayerID());<br>&gt;&nbsp;&nbsp; mypLayer-&gt;setVisible(TRUE);
<br>&gt;<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp; // Create the Map Canvas<br>&gt;&nbsp;&nbsp; QgsMapCanvas * mypMapCanvas = new QgsMapCanvas(0, 0);<br>&gt;&nbsp;&nbsp; mypMapCanvas-&gt;setExtent(mypLayer-&gt;extent());<br>&gt;&nbsp;&nbsp; // cbit qDebug(mypMapCanvas-&gt;extent().stringRep(2));
<br>&gt;<br>&gt;&nbsp;&nbsp; mypMapCanvas-&gt;enableAntiAliasing(true);<br>&gt;&nbsp;&nbsp; mypMapCanvas-&gt;setCanvasColor(QColor(255, 255, 255));<br>&gt;&nbsp;&nbsp; mypMapCanvas-&gt;freeze(false);<br>&gt;&nbsp;&nbsp; // Set the Map Canvas Layer Set<br>&gt;&nbsp;&nbsp; mypMapCanvas-&gt;setLayerSet(myLayerSet);
<br>&gt;&nbsp;&nbsp; mypMapCanvas-&gt;setVisible(true);<br>&gt;&nbsp;&nbsp; mypMapCanvas-&gt;refresh();<br>&gt;&nbsp;&nbsp;// Start the Application Event Loop<br>&gt; //cout&lt;&lt;marker_symbol-&gt;picture().toStdString()&lt;&lt;endl;<br>&gt; app.exec
();<br>&gt;&nbsp;&nbsp;//QgsMapCanvas myMapCanvas(0, 0);<br>&gt;&nbsp;&nbsp;QgsMapLayerRegistry::instance()-&gt;removeAllMapLayers();<br>&gt; return 0;<br>&gt; }<br>&gt;<br>&gt; I created symbol, but don&#39;t know how to add that to the unique value
<br>&gt; renderer.<br>&gt;<br>&gt; Thanking you<br>&gt; cheers<br>&gt; satya<br>&gt;<br>&gt; &gt; On 3/5/07, Tim Sutton &lt;<a href="mailto:tim@linfiniti.com">tim@linfiniti.com</a>&gt; wrote:<br>&gt; &gt; &gt; Hi<br>&gt; &gt; &gt;
<br>&gt; &gt; &gt; How about posting code examples of what you have tried and we can try<br>&gt; &gt; &gt; to help you from there....<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Regards<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Tim<br>
&gt; &gt; &gt;<br>&gt; &gt; &gt; 2007/3/5, satya satya &lt;<a href="mailto:satya341@gmail.com">satya341@gmail.com</a> &gt;:<br>&gt; &gt; &gt; &gt; Hello all,<br>&gt;
&gt; &gt;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
I am trying to develop a simple application using QGis<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; API.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp;I have read all tutorials on QGis blog. I would like to use<br>&gt; &gt; &gt; &gt; &quot;QgsUniqueValueRenderer&quot; in my application to display features in
<br>&gt; &gt; &gt; &gt; diff<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; colors. I tried that&nbsp;&nbsp;&quot;QgsUniqueValueRenderer&quot; , but no luck.<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp;could some body help me .<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp;cheers
<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp;satya<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; _______________________________________________<br>&gt; &gt; &gt; &gt; Qgis-developer mailing list<br>&gt; &gt; &gt; &gt; <a href="mailto:Qgis-developer@lists.qgis.org">
Qgis-developer@lists.qgis.org</a><br>&gt; &gt; &gt; &gt; <a href="http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer">http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer</a><br>&gt; &gt; &gt;<br>&gt; &gt; &gt; --
<br>&gt; &gt; &gt; --<br>&gt; &gt; &gt; Tim Sutton<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Visit <a href="http://qgis.org">http://qgis.org</a> for a great Open Source GIS<br>&gt; &gt; &gt; Home Page: <a href="http://linfiniti.com">
http://linfiniti.com</a><br>&gt; &gt; &gt; Skype: timlinux<br>&gt; &gt; &gt; MSN: <a href="mailto:tim_bdworld@msn.com">tim_bdworld@msn.com</a><br>&gt; &gt; &gt; Yahoo: <a href="mailto:tim_bdworld@yahoo.com">tim_bdworld@yahoo.com
</a><br>&gt; &gt; &gt; Jabber: timlinux<br>&gt; &gt; &gt; Irc: timlinux on #qgis at <a href="http://freenode.net">freenode.net</a><br></blockquote></div><br>