![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QPainterStateGuard is a RAII convenience class for balanced QPainter::save() and QPainter::restore() calls. More...
#include <qpainterstateguard.h>
Public Types | |
enum class | InitialState : quint8 { Save , NoSave } |
Public Member Functions | |
QPainterStateGuard (QPainterStateGuard &&other) noexcept | |
Move-constructs a painter state guard from other. | |
void | swap (QPainterStateGuard &other) noexcept |
Swaps the other with this painter state guard. | |
Q_NODISCARD_CTOR | QPainterStateGuard (QPainter *painter, InitialState state=InitialState::Save) |
Constructs a QPainterStateGuard and calls save() on painter if state is InitialState::Save (which is the default). | |
~QPainterStateGuard () | |
Destroys the QPainterStateGuard instance and calls restore() as often as save() was called to restore the QPainter's state. | |
void | save () |
Calls QPainter::save() and increases the internal save/restore counter by one. | |
void | restore () |
Calls QPainter::restore() if the internal save/restore counter is greater than zero. |
The QPainterStateGuard is a RAII convenience class for balanced QPainter::save() and QPainter::restore() calls.
\inmodule QtGui
\reentrant
QPainterStateGuard should be used everywhere as a replacement for QPainter::save() to make sure that the corresponding QPainter::restore() is called upon finishing of the painting routine to avoid unbalanced calls between those two functions.
Example with QPainter::save()/QPainterrestore():
Example with QPainterStateGuard:
Definition at line 12 of file qpainterstateguard.h.
|
strong |
Enumerator | |
---|---|
Save | |
NoSave |
Definition at line 16 of file qpainterstateguard.h.
|
inlinenoexcept |
Move-constructs a painter state guard from other.
Definition at line 21 of file qpainterstateguard.h.
|
inlineexplicit |
Constructs a QPainterStateGuard and calls save() on painter if state is InitialState::Save
(which is the default).
When QPainterStateGuard is destroyed, restore() is called as often as save() was called to restore the QPainter's state.
Definition at line 33 of file qpainterstateguard.h.
|
inline |
Destroys the QPainterStateGuard instance and calls restore() as often as save() was called to restore the QPainter's state.
Definition at line 41 of file qpainterstateguard.h.
|
inline |
Calls QPainter::restore() if the internal save/restore counter is greater than zero.
Definition at line 54 of file qpainterstateguard.h.
|
inline |
Calls QPainter::save() and increases the internal save/restore counter by one.
Definition at line 47 of file qpainterstateguard.h.
|
inlinenoexcept |
Swaps the other with this painter state guard.
This operation is very fast and never fails.
Definition at line 26 of file qpainterstateguard.h.