Subgroup: Map
Class: QgsMapLayerStyleManager¶
-
class
qgis.core.
QgsMapLayerStyleManager
¶ Bases:
PyQt5.QtCore.QObject
Management of styles for use with one map layer. Stored styles are identified by their names. The manager always keep track of which style of the stored ones is currently active. When the current style is changed, the new style is applied to the associated layer.
The class takes care of updating itself when the layer’s current style configuration changes. When some of layer style’s properties change (e.g. opacity / colors), the style manager will record them in the currently active style without any extra effort required.
When an instance is created, it creates “default” style (with empty name) recorded from the associated map layer and it is set as the current style. The instance must always contain at least one style (which is the current).
The style which is marked as current has no style data stored in its entry. This is to avoid duplication of data as all data is stored in map layer and can be retrieved easily. Also when saving, the entry for the current style will be saved with no data because everything is already saved by the map layer itself.
The class also features support for temporary change of the layer’s style, ideal for short-term use of a custom style followed by restoration of the original style (for example, when rendering a map with a different than current style).
New in version 2.8: Methods
addStyle
Add a style with given name and data addStyleFromLayer
Add style by cloning the current one blockSignals
childEvent
children
connectNotify
currentStyle
Return name of the current style customEvent
deleteLater
disconnect
disconnectNotify
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
event
eventFilter
findChild
findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject findChildren
findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] inherits
installEventFilter
isDefault
Returns true if this is the default style isSignalConnected
isWidgetType
isWindowType
killTimer
layer
Get pointer to the associated map layer mapLayerStyles
Gets available styles for the associated map layer. metaObject
moveToThread
objectName
parent
property
pyqtConfigure
Each keyword argument is either the name of a Qt property or a Qt signal. readXml
Read configuration (for project loading) receivers
removeEventFilter
removeStyle
Remove a stored style renameStyle
Rename a stored style to a different name reset
Reset the style manager to a basic state - with one default style which is set as current restoreOverrideStyle
Restore the original store after a call to setOverrideStyle() sender
senderSignalIndex
setCurrentStyle
Set a different style as the current style - will apply it to the layer setObjectName
setOverrideStyle
Temporarily apply a different style to the layer. setParent
setProperty
signalsBlocked
startTimer
style
Return data of a stored style - accessed by its unique name styles
Return list of all defined style names thread
timerEvent
tr
writeXml
Write configuration (for project saving) Attributes
currentStyleChanged
Emitted when the current style has been changed [signal] destroyed
destroyed(self, QObject = None) [signal] objectNameChanged
objectNameChanged(self, str) [signal] staticMetaObject
styleAdded
Emitted when a new style has been added [signal] styleRemoved
Emitted when a style has been removed [signal] styleRenamed
Emitted when a style has been renamed [signal] -
addStyle
(self, name: str, style: QgsMapLayerStyle) → bool¶ Add a style with given name and data
Returns: true on success (name is unique and style is valid)
-
addStyleFromLayer
(self, name: str) → bool¶ Add style by cloning the current one
Returns: true on success
-
childEvent
()¶
-
connectNotify
()¶
-
currentStyle
(self) → str¶ Return name of the current style
-
currentStyleChanged
¶ Emitted when the current style has been changed [signal]
-
customEvent
()¶
-
disconnectNotify
()¶
-
isDefault
(self, styleName: str) → bool¶ Returns true if this is the default style
New in version 3.0.
-
isSignalConnected
()¶
-
layer
(self) → QgsMapLayer¶ Get pointer to the associated map layer
-
mapLayerStyles
(self) → object¶ Gets available styles for the associated map layer.
Returns: A map of map layer style by style name New in version 3.0.
-
readXml
(self, mgrElement: QDomElement)¶ Read configuration (for project loading)
-
receivers
()¶
-
removeStyle
(self, name: str) → bool¶ Remove a stored style
Returns: true on success (style exists and it is not the last one)
-
renameStyle
(self, name: str, newName: str) → bool¶ Rename a stored style to a different name
Returns: true on success (style exists and new name is unique)
-
reset
(self)¶ Reset the style manager to a basic state - with one default style which is set as current
-
restoreOverrideStyle
(self) → bool¶ Restore the original store after a call to setOverrideStyle()
-
sender
()¶
-
senderSignalIndex
()¶
-
setCurrentStyle
(self, name: str) → bool¶ Set a different style as the current style - will apply it to the layer
Returns: true on success
-
setOverrideStyle
(self, styleDef: str) → bool¶ Temporarily apply a different style to the layer. The argument can be either a style name or a full QML style definition. Each call must be paired with restoreOverrideStyle()
-
style
(self, name: str) → QgsMapLayerStyle¶ Return data of a stored style - accessed by its unique name
-
styleAdded
¶ Emitted when a new style has been added [signal]
-
styleRemoved
¶ Emitted when a style has been removed [signal]
-
styleRenamed
¶ Emitted when a style has been renamed [signal]
-
styles
(self) → List[str]¶ Return list of all defined style names
-
timerEvent
()¶
-
writeXml
(self, mgrElement: QDomElement)¶ Write configuration (for project saving)
-