2

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.

enter image description here

Kadir Şahbaz
78.6k57 gold badges260 silver badges407 bronze badges
asked Dec 10, 2018 at 12:52

1 Answer 1

5

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.

answered Dec 11, 2018 at 0:24
1
  • How can we get the labeling settings for the Layer? Commented Dec 13, 2018 at 8:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.