[Qgis-developer] Tracing errors of the vector layer creation

Eye OnNet eyeonnet2001 at yahoo.com
Sun Apr 24 12:34:16 EDT 2011


Hello.

In my application I execute a simple sequence of QGIS API functions for create vector layer from postgres database:

  QgsDataSourceURI uri = QgsDataSourceURI();
  uri.setConnection(ServerIP,port,dbname,username,password);
  uri.setDataSource(scheme,table,geom,sql);
  QgsVectorLayer *vlayer = new QgsVectorLayer(uri.uri(),"layername", "postgres");
 if(!vlayer->isValid())qDebug(vlayer->lastError()+vlayer->lastErrorTitle());

"isValid()" check failed in application on the one polygon layer but the QGIS opens this layer successful without an error. Both "lastError()" and "lastErrorTitle()" return an empty string... How do to recognize cause of that error?


More information about the Qgis-developer mailing list