Fail to create raster layer in C++ but is able to do so in python

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Fail to create raster layer in C++ but is able to do so in python

eliu1234
I am trying to add a raster layer in c++ application with QtCreator and QGIS 2.6.0. I am currently trying to create a 32bit application under 64 bit windows system. I am not sure if this would be the cause.

My code is as follows:
QgsRasterLayer * layer = new QgsRasterLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json&pretty=true","raster");
However, when I call layer.isValid(), it always return false.

I tried the python equivalent in qgis python console and it works fine. The python code is as follows: layer = QgsRasterLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json&pretty=true","raster");

Any help is appreciated.