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

3

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.

  • How can we get the labeling settings for the Layer? – rughimire Dec 13 '18 at 8:13

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.