<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Thanks for your answer. Now I can use correctly <span
    style="white-space: pre-wrap">QgsCategorizedSymbolRenderer and show markers.

Now I've another question.
I would like put near each marker a label. I can do it in QGIS Desktop 3.26 in section Labels for my vector layer.
Can you suggest a way to do this using qgsi api c++ (Qt 5.15.2 in ubuntu 20.04)

Regards,

Simone

</span>
    <div class="moz-cite-prefix">Il 13/01/2024 12:03, Adam Nielsen ha
      scritto:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20240113210348.62032036@gnosticus.teln.shikadi.net">
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">I created a vector layer and I can show correctly a georeferenced pdf 
image.
Then I added another transparent layer  (vector layer) and I tried to 
add markers in lat,long points.
Using QgsSimpleMarkerSymbolLayer I can inserted correctly all markers of 
the same shape and color. Then I tried to add markers with different 
shapes and colors on the same layers; using QgsSimpleMarkerSymbolLayer I 
show only one kind of marker. Browsing on internet I found an example to 
use QgsCategorizedSymbolRenderer. I tried to implement it in my code but 
no markers shown. Can you suggest a correct way to do this?
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
You should try to do this through the normal QGIS GUI, then once you
have it working in the GUI you will have a better understanding of what
your code needs to achieve.

I haven't tried to do it in code, but:

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">def_symbol->symbolLayers()[0]->setColor(Qt::red);
def_symbol->symbolLayers()[0]->setColor(Qt::blue);
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
Here you're just changing settings on the same symbol, so you'll only
end up with one symbol.

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">QgsCategorizedSymbolRenderer*categorizedRenderer=newQgsCategorizedSymbolRenderer("Category");
QgsRendererCategorybsprxCategory("A",def_symbol->clone(),"RX",true);
categorizedRenderer->addCategory(bsprxCategory);

QgsRendererCategorybsptxCategory("B",def_symbol->clone(),"TX",true);
categorizedRenderer->addCategory(bsptxCategory);
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
Here you're saying when your Category field is "A", use the same symbol
as when your Category field is "B".  You'll have to assign different
symbols if you want them to appear differently.

I guess you want to call def_symbol->clone() first, then change the
colour on the clone, before assigning it to Category A or B.

Cheers,
Adam.
</pre>
    </blockquote>
    <br>
    <div class="moz-signature">-- <br>
      <img src="cid:part1.8WFtgEZz.jQ902Vdr@leonardo-si.it" border="0"></div>
  <div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br /><table style="border-top: 1px solid #D3D4DE;"><tr><td style="width: 55px; padding-top: 13px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://s-install.avcdn.net/ipm/preview/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"/></a></td><td style="width: 470px; padding-top: 12px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Privo di virus.<a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a></td></tr></table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>