I am working in c++ qt4.8.5 and api qgis 2.8.2 c++.In my application I had to put polygon to define attractive zone.I found a great post in stackexchange (86812).I have based my on this post and on the pyqgis cookbook,but in c++ it seems that it is more difficult.I create a layer in memory with a polygon type,then i create a function to generate ( for the moment ) a random polygon shape with 10 points.There is no error in the build, when i call the function there is nothing on the display.I check the coordinate of the point it is ok.
here is my code
create the polygon layer :
QgsVectorLayer * lVectorLayer = new QgsVectorLayer("Polygon",pType,"memory");lVectorLayer->isValid();qDebug() addMapLayer(lVectorLayer);// insert the vector layer into the vectorlayermapmMapLayer.insert(pType, lVectorLayer);// Add the Layer to the Layer SetQgsMapCanvasLayer PolygonLayer = QgsMapCanvasLayer(lVectorLayer, TRUE);mpS57->myListForPrint.insert(1,PolygonLayer);// Set the Map Canvas Layer SetmpMapCanvas->setLayerSet(mpS57->myListForPrint);then the function to create the random polygon :
QgsVectorLayer * lLayer = mMapLayer.value(pType);if (lLayer == NULL) qDebug()
here is my code
create the polygon layer :
QgsVectorLayer * lVectorLayer = new QgsVectorLayer("Polygon",pType,"memory");lVectorLayer->isValid();qDebug() addMapLayer(lVectorLayer);// insert the vector layer into the vectorlayermapmMapLayer.insert(pType, lVectorLayer);// Add the Layer to the Layer SetQgsMapCanvasLayer PolygonLayer = QgsMapCanvasLayer(lVectorLayer, TRUE);mpS57->myListForPrint.insert(1,PolygonLayer);// Set the Map Canvas Layer SetmpMapCanvas->setLayerSet(mpS57->myListForPrint);then the function to create the random polygon :
QgsVectorLayer * lLayer = mMapLayer.value(pType);if (lLayer == NULL) qDebug()