[QGIS-Developer] Problem reading project file
Jörg Höttges
hoettges at fh-aachen.de
Fri May 5 06:47:47 PDT 2017
Hi,
in a QGIS-plugin I need to read a template project file (*.qgs), modify it to adapt it to the currently loaded database
etc. using xml.etree.ElementTree, write it and read it again.
....
qgsxml.write(projectfile) # writemodified project file
project = QgsProject.instance()
project.read(QFileInfo(projectfile)) # read the new project file
projectfilecontains the name of the new *.qgs projectfile
First attempt is successful, the second fails (groups are loaded but there are no layers), third attempt is successful,
fourth fails and so on...
Everything works fine when I use the menu "project > new" before starting the plugin.
Have i done something wrong?
Best wishes
Jörg
FH Aachen
Prof. Dr.-Ing. Jörg Höttges
Fachbereich 2 - Bauingenieurwesen
Wasserwirtschaft und Bauinformatik
FH Aachen
University of Applied Sciences
Bayernallee 9
52066 Aachen | Germany
T +49 (0)241 6009-51176
F +49 (0)241 6009-51206
http://www.fh-aachen.de/hoettges/
hoettges at fh-aachen.de <mailto:hoettges at fh-aachen.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170505/2a2b72b2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ihobgfpmjnpaefje.png
Type: image/png
Size: 839 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170505/2a2b72b2/attachment.png>
More information about the QGIS-Developer
mailing list