QGIS: Default constructor for QgsVectorLayer and QgsRasterLayer?
I'm trying to create a Windows Forms control using the QGIS API and a pre-defined QGIS project file, so that I can set X and Y properties on the Windows Forms control and the QGIS API will show the predefined map data in the Control, focused at the supplied coordinates.
Using QgsProject::instance()->read() seems to cause an unhandled exception (Access violation reading location 0x00000000), so I'm trying to pick through the actual code line by line. There's a portion of qgsproject.cpp that deals with extracting layers from a project file and then adding them to the map canvas that says:
QgsMapLayer *mapLayer = null;
if(type=="vector")
mapLayer = new QgsVectorLayer;
else if(type==""raster")
mapLayer = new QgsRasterLayer;
Where type is the value开发者_运维技巧 of the element 'type' attribute.
When I try to compile this in my Visual Studio project, it complains that there is no default constructor for either type of map layer. The only constructors avaiable to me require paths and basenames, and don't seem to actually work (hence trying to use the same methods as the gui given that the project file does load in the full application gui).
The default constructor for the QgsRasterLayer doesn't even seem to be a private member function. Does anyone know how aI would go about making this compile?
Thanks, Rik
Just a guess: Do you use Visual Studio 2008? http://hub.qgis.org/wiki/quantum-gis/Building_QGIS_from_Source#Building-with-Microsoft-Visual-Studio indicates that the QGIS binaries (I assume that you're using them) are build using Visual Studio 2008 - if you use a different compiler version, you might encounter runtime mixing problems.
精彩评论