Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
src_gui_painting_qpainterpath.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QLinearGradient>
4#include <QPainter>
5#include <QPainterPath>
6#include <QPen>
7
10{
12
13 void wrapper0();
14 void wrapper1();
15 void wrapper2();
16 void wrapper3();
17 void wrapper4();
18 void wrapper5();
19 void wrapper6();
20 void wrapper7();
21};
22
24
27path.addRect(20, 20, 60, 60);
28
29path.moveTo(0, 0);
30path.cubicTo(99, 0, 50, 50, 99, 99);
31path.cubicTo(0, 99, 50, 50, 0, 0);
32
33QPainter painter(this);
34painter.fillRect(0, 0, 100, 100, Qt::white);
35painter.setPen(QPen(QColor(79, 106, 25), 1, Qt::SolidLine,
37painter.setBrush(QColor(122, 163, 39));
38
41
42} // Wrapper::wrapper0
43
44
46const QPointF c1;
47const QPointF c2;
48const QPointF endPoint;
49
51QLinearGradient myGradient;
52QPen myPen;
53
54QPainterPath myPath;
55myPath.cubicTo(c1, c2, endPoint);
56
57QPainter painter(this);
58painter.setBrush(myGradient);
59painter.setPen(myPen);
60painter.drawPath(myPath);
62
63} // Wrapper::wrapper1
64
65
68qreal startAngle = 0;
69qreal sweepLength = 0;
70QPointF center;
71QLinearGradient myGradient;
72QPen myPen;
74QPainterPath myPath;
75myPath.moveTo(center);
76myPath.arcTo(boundingRect, startAngle,
77 sweepLength);
78
79QPainter painter(this);
80painter.setBrush(myGradient);
81painter.setPen(myPen);
82painter.drawPath(myPath);
84
85} // Wrapper::wrapper2
86
87
89
91QLinearGradient myGradient;
92QPen myPen;
93QRectF myRectangle;
94
95QPainterPath myPath;
96myPath.addRect(myRectangle);
97
98QPainter painter(this);
99painter.setBrush(myGradient);
100painter.setPen(myPen);
101painter.drawPath(myPath);
103
104} // Wrapper::wrapper3
105
106
108
110QLinearGradient myGradient;
111QPen myPen;
112QPolygonF myPolygon;
113
114QPainterPath myPath;
115myPath.addPolygon(myPolygon);
116
117QPainter painter(this);
118painter.setBrush(myGradient);
119painter.setPen(myPen);
120painter.drawPath(myPath);
122
123} // Wrapper::wrapper4
124
125
127
129QLinearGradient myGradient;
130QPen myPen;
131QRectF boundingRectangle;
132
133QPainterPath myPath;
134myPath.addEllipse(boundingRectangle);
135
136QPainter painter(this);
137painter.setBrush(myGradient);
138painter.setPen(myPen);
139painter.drawPath(myPath);
141
142} // Wrapper::wrapper5
143
144
146qreal x = 0;
147qreal y = 0;
148
150QLinearGradient myGradient;
151QPen myPen;
152QFont myFont;
153QPointF baseline(x, y);
154
155QPainterPath myPath;
156myPath.addText(baseline, myFont, tr("Qt"));
157
158QPainter painter(this);
159painter.setBrush(myGradient);
160painter.setPen(myPen);
161painter.drawPath(myPath);
163
164
165} // Wrapper::wrapper6
166} // src_gui_painting_qpainterpath
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\reentrant
Definition qfont.h:22
\inmodule QtGui
Definition qbrush.h:394
\inmodule QtGui
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
void addEllipse(const QRectF &rect)
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed...
void addPolygon(const QPolygonF &polygon)
Adds the given polygon to the path as an (unclosed) subpath.
void addText(const QPointF &point, const QFont &f, const QString &text)
Adds the given text to this path as a set of closed subpaths created from the font supplied.
void cubicTo(const QPointF &ctrlPt1, const QPointF &ctrlPt2, const QPointF &endPt)
Adds a cubic Bezier curve between the current position and the given endPoint using the control point...
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling.
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
\inmodule QtGui
Definition qpen.h:28
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QPolygonF class provides a list of points using floating point precision.
Definition qpolygon.h:96
\inmodule QtCore\reentrant
Definition qrect.h:484
@ white
Definition qnamespace.h:31
@ SolidLine
@ MiterJoin
@ FlatCap
GLint GLint GLint GLint GLint x
[0]
GLint y
GLsizei const GLchar *const * path
static const QRectF boundingRect(const QPointF *points, int pointCount)
#define tr(X)
#define Q_OBJECT
double qreal
Definition qtypes.h:187
MyCustomStruct c2
QPainter painter(this)
[7]