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
qstylepainter.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
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
"qstylepainter.h"
6
7
QT_BEGIN_NAMESPACE
8
9
/*!
10
\class QStylePainter
11
12
\brief The QStylePainter class is a convenience class for drawing QStyle
13
elements inside a widget.
14
15
\ingroup appearance
16
\ingroup painting
17
\inmodule QtWidgets
18
19
QStylePainter extends QPainter with a set of high-level \c
20
draw...() functions implemented on top of QStyle's API. The
21
advantage of using QStylePainter is that the parameter lists get
22
considerably shorter. Whereas a QStyle object must be able to
23
draw on any widget using any painter (because the application
24
normally has one QStyle object shared by all widget), a
25
QStylePainter is initialized with a widget, eliminating the need
26
to specify the QWidget, the QPainter, and the QStyle for every
27
function call.
28
29
Example using QStyle directly:
30
31
\snippet styles/styles.cpp 1
32
33
Example using QStylePainter:
34
35
\snippet styles/styles.cpp 0
36
\snippet styles/styles.cpp 4
37
\snippet styles/styles.cpp 6
38
39
\sa QStyle, QStyleOption
40
*/
41
42
/*!
43
\fn QStylePainter::QStylePainter()
44
45
Constructs a QStylePainter.
46
*/
47
48
/*!
49
\fn QStylePainter::QStylePainter(QWidget *widget)
50
51
Construct a QStylePainter using widget \a widget for its paint device.
52
*/
53
54
/*!
55
\fn QStylePainter::QStylePainter(QPaintDevice *pd, QWidget *widget)
56
57
Construct a QStylePainter using \a pd for its paint device, and
58
attributes from \a widget.
59
*/
60
61
62
/*!
63
\fn bool QStylePainter::begin(QWidget *widget)
64
65
Begin painting operations on the specified \a widget.
66
Returns \c true if the painter is ready to use; otherwise returns \c false.
67
68
This is automatically called by the constructor that takes a QWidget.
69
*/
70
71
/*!
72
\fn bool QStylePainter::begin(QPaintDevice *pd, QWidget *widget)
73
\overload
74
75
Begin painting operations on paint device \a pd as if it was \a
76
widget.
77
78
This is automatically called by the constructor that
79
takes a QPaintDevice and a QWidget.
80
*/
81
82
83
/*!
84
\fn void QStylePainter::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &option)
85
86
Use the widget's style to draw a primitive element \a pe specified by QStyleOption \a option.
87
88
\sa QStyle::drawPrimitive()
89
*/
90
91
/*!
92
\fn void QStylePainter::drawControl(QStyle::ControlElement ce, const QStyleOption &option)
93
94
Use the widget's style to draw a control element \a ce specified by QStyleOption \a option.
95
96
\sa QStyle::drawControl()
97
*/
98
99
/*!
100
\fn void QStylePainter::drawComplexControl(QStyle::ComplexControl cc,
101
const QStyleOptionComplex &option)
102
103
Use the widget's style to draw a complex control \a cc specified by the
104
QStyleOptionComplex \a option.
105
106
\sa QStyle::drawComplexControl()
107
*/
108
109
/*!
110
\fn void QStylePainter::drawItemText(const QRect &rect, int flags, const QPalette &pal,
111
bool enabled, const QString &text,
112
QPalette::ColorRole textRole = QPalette::NoRole)
113
114
Draws the \a text in rectangle \a rect and palette \a pal.
115
The text is aligned and wrapped according to \a
116
flags.
117
118
The pen color is specified with \a textRole. The \a enabled bool
119
indicates whether or not the item is enabled; when reimplementing
120
this bool should influence how the item is drawn.
121
122
\sa QStyle::drawItemText(), Qt::Alignment
123
*/
124
125
/*!
126
\fn void QStylePainter::drawItemPixmap(const QRect &rect, int flags, const QPixmap &pixmap)
127
128
Draws the \a pixmap in rectangle \a rect.
129
The pixmap is aligned according to \a flags.
130
131
\sa QStyle::drawItemPixmap(), Qt::Alignment
132
*/
133
134
/*!
135
\fn QStyle *QStylePainter::style() const
136
137
Return the current style used by the QStylePainter.
138
*/
139
140
QT_END_NAMESPACE
QPlatformGraphicsBufferHelper
\inmodule QtGui
qtbase
src
widgets
styles
qstylepainter.cpp
Generated on
for Qt by
1.14.0