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