Class: QgsRecentStyleHandler¶
Handles and tracks style items recently used in the QGIS GUI.
QgsRecentStyleHandler
is not usually directly created, but
rather accessed through QgsApplication.recentStyleHandler()
.
Added in version 3.22.
Methods
Pushes a recently used symbol with the specified identifier. |
|
Returns a copy of the recently used symbol with the specified identifier, or |
- class qgis.core.QgsRecentStyleHandler[source]¶
Bases:
object
- __init__()
Creates a new recent style handler.
QgsRecentStyleHandler is not usually directly created, but rather accessed through
QgsApplication.recentStyleHandler()
.
- pushRecentSymbol(self, identifier: str | None, symbol: QgsSymbol | None)[source]¶
Pushes a recently used
symbol
with the specifiedidentifier
.Ownership of
symbol
is transferred.Example¶
# create a new simple fill symbol my_fill_symbol = QgsFillSymbol.createSimple( { 'color': '#ff0000' } ) # push this symbol to the recent style handler, using a custom identifier "fill_symbol_for_new_rectangles" QgsApplication.recentStyleHandler().pushRecentSymbol( 'fill_symbol_for_new_rectangles', my_fill_symbol ) # ... later in the same QGIS session, retrieve a copy of this symbol so that we can use it for a newly created rectangle new_symbol = QgsApplication.recentStyleHandler().recentSymbol( 'fill_symbol_for_new_rectangles' )
See also
- param identifier:
- type identifier:
Optional[str]
- param symbol:
- type symbol:
Optional[QgsSymbol]
- recentSymbol(self, identifier: str | None) QgsSymbol | None [source]¶
Returns a copy of the recently used symbol with the specified
identifier
, orNone
if no symbol with the identifier exists.Caller takes ownership of the returned object.
See also
- Parameters:
identifier (Optional[str])
- Return type:
Optional[QgsSymbol]