I think I have hit a similar problem recently. OGR should be able to
load shapefiles with 2 different ways:
1. layer path is directory, layer name is shapefile's name (without extension)
2. layer path is whole path to the layer and layer name is its base name

First option (used in tutorial) didn't work for me as expected so I've
used second one, e.g.:

QString myLayerPath = "/data/gis/mylayer.shp";
QString myLayerBaseName = "mylayer";
QString myProviderName = "ogr";

QgsVectorLayer * mypLayer =
      new QgsVectorLayer(myLayerPath, myLayerBaseName, myProviderName);


On 12/1/06, Patrick Desautels <[EMAIL PROTECTED]> wrote:
Hi everyone,

We tried to follow tutorial 1 ("Write a sample mapping application using new
QGIS Canvas API") and tutorial 2 ("Using Map Tools with the QGIS Canvas API" to
create an application based on QGIS librairies (under Windows, Qt4.2, compil
with mingw). We got problems trying to show not one, but two default layers at
start. Indeed, the program does not take layers identified by
"myLayerBaseName", but the first one according to alphabetical order (in
"myLayerPath"). The path "myLayerPath" is the right one, tough. We tried many
changes to that code, but none gave us the answer.

Someone got a cue?
Thanks in advance.

Qgis-user mailing list

Reply via email to