<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.5726" name=GENERATOR><LINK
href="BLOCKQUOTE{margin-Top: 0px; margin-Bottom: 0px; margin-Left: 2em}"
rel=stylesheet></HEAD>
<BODY style="FONT-SIZE: 10pt; MARGIN: 10px; FONT-FAMILY: verdana">
<DIV><FONT face=Verdana size=2>hi, all</FONT></DIV>
<DIV> </DIV>
<DIV>I am trying to compile qgis's example code "hello world" . </DIV>
<DIV>it has some code like these:</DIV>
<DIV> </DIV>
<DIV>
<TABLE
style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; FONT-SIZE: 10pt; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse"
borderColor=#000000 cellSpacing=0 cellPadding=2 width="50%" border=1>
<TBODY>
<TR>
<TD
style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid"
noWrap width="100%"><FONT face=Verdana size=2>
<DIV>
<DIV>QString myLayerPath = "xxx.shp";</DIV>
<DIV> QString myLayerBaseName = "xxx";</DIV>
<DIV> QString myProviderName = "ogr";</DIV>
<DIV> // Instantiate Provider Registry</DIV>
<DIV> QgsProviderRegistry::instance(myPluginsDir);</DIV>
<DIV> // create a maplayer instance</DIV>
<DIV> QgsVectorLayer * mypLayer = </DIV>
<DIV> new QgsVectorLayer(myLayerPath, myLayerBaseName);</DIV>
<DIV> QgsSingleSymbolRenderer *mypRenderer = new QgsSingleSymbolRenderer(mypLayer->geometryType());</DIV>
<DIV> QList <QgsMapCanvasLayer> myLayerSet;</DIV>
<DIV> mypLayer->setRenderer(mypRenderer);</DIV>
<DIV> if (mypLayer->isValid())</DIV>
<DIV> {</DIV>
<DIV> qDebug("Layer is valid");</DIV>
<DIV> }</DIV>
<DIV> else</DIV>
<DIV> {</DIV>
<DIV> qDebug("Layer is NOT valid");</DIV>
<DIV> }</DIV></DIV></FONT></TD></TR></TBODY></TABLE></DIV>
<DIV> </DIV>
<DIV>When i run it. it always goes to "Layer is NOT valid" . But
my shp file exists in the same directory.</DIV>
<DIV> </DIV>
<DIV>I assign myLayerPath with full path like
"c:\\qgisexample\\xxx.shp" , and the result goes the same.</DIV>
<DIV> </DIV>
<DIV>What would the problem be ? Any help will be appreciated , thank
you.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV align=left><FONT face=Verdana color=#c0c0c0 size=2>2009-04-22
</FONT></DIV><FONT face=Verdana size=2>
<HR style="WIDTH: 122px; HEIGHT: 2px" align=left SIZE=2>
<DIV><FONT face=Verdana color=#c0c0c0 size=2><SPAN>hermangz</SPAN>
</FONT></DIV></FONT></BODY></HTML>