QGIS API Documentation 4.3.0-Master (96c7fa699b4)
Loading...
Searching...
No Matches
QgsScopedQPainterState Class Reference

Scoped object for saving and restoring a QPainter object's state. More...

#include <qgspainting.h>

Public Types

enum class  InitialState { Save , NoSave }
 Initial action to take when constructing the scoped object. More...

Public Member Functions

 QgsScopedQPainterState (const QgsScopedQPainterState &)=delete
 QgsScopedQPainterState (QgsScopedQPainterState &&)=delete
 QgsScopedQPainterState (QPainter *painter, InitialState initialState=InitialState::Save)
 Constructor for QgsScopedQPainterState.
 ~QgsScopedQPainterState ()
 Restores the painter back to its original state.
QgsScopedQPainterState & operator= (const QgsScopedQPainterState &)=delete
QgsScopedQPainterState & operator= (QgsScopedQPainterState &&)=delete
void restore ()
 Performs a manual restore on the painter state, popping the latest state from the painter.
void save ()
 Performs a manual save on the painter state, pushing another saved state to the painter.

Detailed Description

Scoped object for saving and restoring a QPainter object's state.

Temporarily saves the QPainter state for the lifetime of the object, before restoring it on destruction.

Since QGIS 4.4 this class supports multiple saved states, and early restoration of state.

Note
Not available in Python bindings
Since
QGIS 3.16

Definition at line 166 of file qgspainting.h.

Member Enumeration Documentation

◆ InitialState

Initial action to take when constructing the scoped object.

Enumerator
Save 

Immediately save the current painter state.

NoSave 

Do not save the current painter state.

Definition at line 172 of file qgspainting.h.

Constructor & Destructor Documentation

◆ QgsScopedQPainterState() [1/3]

QgsScopedQPainterState::QgsScopedQPainterState ( QPainter * painter,
InitialState initialState = InitialState::Save )
inline

Constructor for QgsScopedQPainterState.

Saves the specified painter state.

Definition at line 183 of file qgspainting.h.

◆ ~QgsScopedQPainterState()

QgsScopedQPainterState::~QgsScopedQPainterState ( )
inline

Restores the painter back to its original state.

Definition at line 196 of file qgspainting.h.

◆ QgsScopedQPainterState() [2/3]

QgsScopedQPainterState::QgsScopedQPainterState ( const QgsScopedQPainterState & )
delete

◆ QgsScopedQPainterState() [3/3]

QgsScopedQPainterState::QgsScopedQPainterState ( QgsScopedQPainterState && )
delete

Member Function Documentation

◆ operator=() [1/2]

QgsScopedQPainterState & QgsScopedQPainterState::operator= ( const QgsScopedQPainterState & )
delete

◆ operator=() [2/2]

QgsScopedQPainterState & QgsScopedQPainterState::operator= ( QgsScopedQPainterState && )
delete

◆ restore()

void QgsScopedQPainterState::restore ( )
inline

Performs a manual restore on the painter state, popping the latest state from the painter.

See also
save()
Since
QGIS 4.4

Definition at line 216 of file qgspainting.h.

◆ save()

void QgsScopedQPainterState::save ( )
inline

Performs a manual save on the painter state, pushing another saved state to the painter.

See also
restore()
Since
QGIS 4.4

Definition at line 230 of file qgspainting.h.


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