I am using PyQGIS API
for developing the standalone application to load the certain VectorLayers
. I used the QgsMapCanvas
to load the map and QgsLayerTreeView
to show the layer tree view using code below-
# Layer Tree View
self.layerTreeRoot = QgsProject.instance().layerTreeRoot()
self.layerTreeModel = QgsLayerTreeModel(self.layerTreeRoot)
self.layerTreeView = QgsLayerTreeView()
self.layerTreeView.setModel(self.layerTreeModel)
self.layoutWidgetLayout = QHBoxLayout()
self.layoutWidgetLayout.addWidget(self.layerTreeView)
self.layerWidget.setLayout(self.layoutWidgetLayout)
Now I want to style the layer and change some behaviors of the style using Layer Properties. How can I get that LayerPropertiesWindow
by context menu of Layer as below.
Answer
The full Layer Properties window is not part of the PyQGIS API. Basically, it's part of the "app" library within QGIS, which is code which is only available when running the full QGIS desktop application and accordingly cannot be reused from a standalone script.
However, some individual parts of this dialog ARE exposed via the PyQGIS API and can be reused. Specifically the symbology and labeling settings are reusable widgets (e.g. qgis.gui.QgsSingleSymbolRendererWidget). You could manually construct these widgets in your standalone script to partly re-implement the layer properties dialog.
No comments:
Post a Comment