[Qgis-developer] Open a *.qgs project file in API, why maps do not show?

Gary Sherman gsherman at geoapt.com
Mon Oct 20 19:18:40 PDT 2014


On 10/20/14 6:10 PM, Tendfly niu wrote:
> Hi all,
> I'm using QGIS-2.4.0 API. I saved a test.qgs file in QGIS Desktop, in
> this project, there is one layer in it.
>
> Then I open the test.qgs project file in QGIS API to developing, but it
> is not showed in APP.
>
> Why is that?
> The code I'm using to open the project is:
>      QString myProjectPath = "E:\\QGIS\\Pro\\test.qgs";
>      Qgsproject::instance()->setFileName(myProjectPath);
>      bool isRead = QgsProject::instance()->read();
>
> In Debug mode, isRead equals TRUE.
>

Use:

iface.addProject(myProjectPath)


> Any advice would be appreciated!
>
> Regards,
>
> Bob
>
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>


-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Gary Sherman

Founder, QGIS Project
Consulting: geoapt.com
Publishing: locatepress.com

We work virtually anywhere
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


More information about the Qgis-developer mailing list