QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsRecentStyleHandler Class Reference

Handles and tracks style items recently used in the QGIS GUI. More...

#include <qgsrecentstylehandler.h>

Public Member Functions

 QgsRecentStyleHandler ()
 Creates a new recent style handler.
 
 QgsRecentStyleHandler (const QgsRecentStyleHandler &other)=delete
 
 ~QgsRecentStyleHandler ()
 
QgsRecentStyleHandleroperator= (const QgsRecentStyleHandler &other)=delete
 
void pushRecentSymbol (const QString &identifier, QgsSymbol *symbol)
 Pushes a recently used symbol with the specified identifier.
 
QgsSymbolrecentSymbol (const QString &identifier) const
 Returns a copy of the recently used symbol with the specified identifier, or nullptr if no symbol with the identifier exists.
 
template<class SymbolType >
std::unique_ptr< SymbolType > recentSymbol (const QString &identifier) const
 Returns a copy of the recently used symbol with the specified identifier, or nullptr if no symbol with the identifier exists, and casts it to a particular symbol type.
 

Detailed Description

Handles and tracks style items recently used in the QGIS GUI.

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

Since
QGIS 3.22

Definition at line 38 of file qgsrecentstylehandler.h.

Constructor & Destructor Documentation

◆ QgsRecentStyleHandler() [1/2]

QgsRecentStyleHandler::QgsRecentStyleHandler ( )
default

Creates a new recent style handler.

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

◆ QgsRecentStyleHandler() [2/2]

QgsRecentStyleHandler::QgsRecentStyleHandler ( const QgsRecentStyleHandler other)
delete

◆ ~QgsRecentStyleHandler()

QgsRecentStyleHandler::~QgsRecentStyleHandler ( )
default

Member Function Documentation

◆ operator=()

QgsRecentStyleHandler & QgsRecentStyleHandler::operator= ( const QgsRecentStyleHandler other)
delete

◆ pushRecentSymbol()

void QgsRecentStyleHandler::pushRecentSymbol ( const QString &  identifier,
QgsSymbol symbol 
)

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' )
static QgsRecentStyleHandler * recentStyleHandler()
Returns the handler for recently used style items.
static QgsFillSymbol * createSimple(const QVariantMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties.
See also
recentSymbol()

Definition at line 24 of file qgsrecentstylehandler.cpp.

◆ recentSymbol() [1/2]

QgsSymbol * QgsRecentStyleHandler::recentSymbol ( const QString &  identifier) const

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

Caller takes ownership of the returned object.

See also
pushRecentSymbol()

Definition at line 29 of file qgsrecentstylehandler.cpp.

◆ recentSymbol() [2/2]

template<class SymbolType >
std::unique_ptr< SymbolType > QgsRecentStyleHandler::recentSymbol ( const QString &  identifier) const
inline

Returns a copy of the recently used symbol with the specified identifier, or nullptr if no symbol with the identifier exists, and casts it to a particular symbol type.

Note
not available in Python bindings
See also
pushRecentSymbol()

Definition at line 94 of file qgsrecentstylehandler.h.


The documentation for this class was generated from the following files: