如何使用Python从QGIS项目文件读取/写入QGIS项目文件?


9

我想将我的Python插件的项目相关配置保存在QGIS项目文件中。这有可能吗,什么是最佳做法?

Answers:


9

应该这样做:

QgsProject.instance().writeEntry(plugin_name, property, value)

然后,您只需要保存项目。

使用以下功能之一执行读取:

readEntry (plugin_name, property)
readNumEntry (plugin_name, property)
readDoubleEntry (plugin_name, property)
readBoolEntry (plugin_name, property)

Doc:http : //qgis.org/api/classQgsProject.html

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.