2

I am loading a project with:

QgsProject.instance().read(QFileInfo(path))

When i try to load another project it subtracts the layers and shows nothing. But if I try doing it again it works.

  • Which QGIS version are you using? – Joseph Jan 7 '16 at 12:36
  • I'm using version 2.10 – okorkut Jan 7 '16 at 14:34
  • Can't seem to replicate your issue. I tested it on QGIS 2.6.1, 2.8.2, 2.10.1 and 2.12.0 for Windows, all of which loads the project immediately. Are you also using Windows? Could you test it on another QGIS version? – Joseph Jan 7 '16 at 14:41
  • QgsProject.instance().clear() QgsProject.instance().read(QFileInfo("~/project1.qgs")) QgsProject.instance().read(QFileInfo("~/project2.qgs")) project1 has 2 layers. project2 also has these 2 layers plus another layer. When executed canvas shows only one layer that was not in project1. – okorkut Jan 8 '16 at 12:10
  • Perhaps you neet to call iface.newProject() before reading a new project. – Germán Carrillo Jun 26 '17 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.