Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qpainterstateguard.cpp
Go to the documentation of this file.
1
// Copyright (C) 2024 Christian Ehrlicher <ch.ehrlicher@gmx.de>
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qpainterstateguard.h"
6
7
QT_BEGIN_NAMESPACE
8
9
/*!
10
\class QPainterStateGuard
11
\brief The QPainterStateGuard is a RAII convenience class for balanced
12
QPainter::save() and QPainter::restore() calls.
13
\since 6.9
14
15
\inmodule QtGui
16
\ingroup painting
17
18
\reentrant
19
20
\sa QPainter
21
22
QPainterStateGuard should be used everywhere as a replacement for QPainter::save()
23
to make sure that the corresponding QPainter::restore() is called upon finishing
24
of the painting routine to avoid unbalanced calls between those two functions.
25
26
Example with QPainter::save()/QPainter::restore():
27
\snippet code/src_gui_painting_qpainterstateguard.cpp 0
28
29
Example with QPainterStateGuard:
30
\snippet code/src_gui_painting_qpainterstateguard.cpp 1
31
*/
32
33
/*!
34
\fn QPainterStateGuard::QPainterStateGuard(QPainter *painter, InitialState state = InitialState::Save)
35
Constructs a QPainterStateGuard and calls save() on \a painter if \a state
36
is \c InitialState::Save (which is the default). When QPainterStateGuard is
37
destroyed, restore() is called as often as save() was called to restore the
38
QPainter's state.
39
*/
40
41
/*!
42
\fn QPainterStateGuard::QPainterStateGuard(QPainterStateGuard &&other)
43
44
Move-constructs a painter state guard from \a other.
45
*/
46
47
/*!
48
\fn QPainterStateGuard &QPainterStateGuard::operator=(QPainterStateGuard &&other)
49
50
Move-assigns \a other to this painter state guard.
51
*/
52
53
/*!
54
\fn void QPainterStateGuard::swap(QPainterStateGuard &other)
55
56
Swaps the \a other with this painter state guard. This operation is very
57
fast and never fails.
58
*/
59
60
/*!
61
\fn QPainterStateGuard::~QPainterStateGuard()
62
Destroys the QPainterStateGuard instance and calls restore() as often as save()
63
was called to restore the QPainter's state.
64
*/
65
66
/*!
67
\fn void QPainterStateGuard::save()
68
Calls QPainter::save() and increases the internal save/restore counter by one.
69
*/
70
71
/*!
72
\fn void QPainterStateGuard::restore()
73
Calls QPainter::restore() if the internal save/restore counter is greater than zero.
74
75
\note This function asserts in debug builds if the counter has already reached zero.
76
*/
77
78
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
qtbase
src
gui
painting
qpainterstateguard.cpp
Generated on
for Qt by
1.16.1