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 through QgsApplication.recentStyleHandler().

New in version 3.22.

QgsRecentStyleHandler() Creates a new recent style handler.

QgsRecentStyleHandler is not usually directly created, but rather accessed through QgsApplication.recentStyleHandler().

Methods

pushRecentSymbol

Pushes a recently used symbol with the specified identifier.

recentSymbol

Returns a copy of the recently used symbol with the specified identifier, or None if no symbol with the identifier exists.

pushRecentSymbol(self, identifier: str, symbol: QgsSymbol)

Pushes a recently used symbol with the specified identifier.

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

recentSymbol()

param identifier

type identifier

str

param symbol

type symbol

QgsSymbol

recentSymbol(self, identifier: str) QgsSymbol

Returns a copy of the recently used symbol with the specified identifier, or None if no symbol with the identifier exists.

Caller takes ownership of the returned object.

Parameters

identifier (str) –

Return type

QgsSymbol