Class: QgsRecentStyleHandler¶
- class qgis.core.QgsRecentStyleHandler¶
Bases:
sip.wrapper
Handles and tracks style items recently used in the QGIS GUI.
QgsRecentStyleHandler
is not usually directly created, but rather accessed throughQgsApplication.recentStyleHandler()
.Added in version 3.22.
QgsRecentStyleHandler() Creates a new recent style handler.
QgsRecentStyleHandler
is not usually directly created, but rather accessed throughQgsApplication.recentStyleHandler()
.Methods
Pushes a recently used
symbol
with the specifiedidentifier
.Returns a copy of the recently used symbol with the specified
identifier
, orNone
if no symbol with the identifier exists.- pushRecentSymbol(self, identifier: str | None, symbol: QgsSymbol | None)¶
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 ¶
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]