Re: Disaplying a vector layer

Hi

Indeed the API has changed a little and I probably need to go through and update all my tutorials. For now I can point you to a working example in my openModeller Desktop code:

OmgMainWindow source

If you look at around line 1479 in that file you will see I start by creating a vector layer, set some symbolisation properties for it and then at around lines

 1565             QgsMapLayerRegistry::instance()->addMapLayer(mypVectorLayer, TRUE);
 1566             myList.append(QgsMapCanvasLayer(mypVectorLayer, TRUE)); //bool visibility

The layer is added to the registry and also appended to a QList.

Finally this line adds my layers list to the canvas:

1673   mpMapCanvas->setLayerSet(myList);

Hope that helps!

Regards

Tim

Reply