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
qpen.h
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#ifndef QPEN_H
6#define QPEN_H
7
8#include <QtCore/qshareddata.h>
9#include <QtGui/qtguiglobal.h>
10#include <QtGui/qcolor.h>
11#include <QtGui/qbrush.h>
12
14
15
16class QVariant;
17class QPenPrivate;
18class QBrush;
19class QPen;
20
21#ifndef QT_NO_DATASTREAM
22Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
23Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
24#endif
25
26QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QPenPrivate, Q_GUI_EXPORT)
27
28class Q_GUI_EXPORT QPen
29{
30public:
31 QPen();
32 QPen(Qt::PenStyle);
33 QPen(const QColor &color);
34 QPen(const QBrush &brush, qreal width, Qt::PenStyle s = Qt::SolidLine,
35 Qt::PenCapStyle c = Qt::SquareCap, Qt::PenJoinStyle j = Qt::BevelJoin);
36 QPen(const QPen &pen) noexcept;
37
38 ~QPen();
39
40 QPen &operator=(const QPen &pen) noexcept;
41 QPen(QPen &&other) noexcept = default;
42 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPen)
43 void swap(QPen &other) noexcept { d.swap(other.d); }
44
45 QPen &operator=(QColor color);
46 QPen &operator=(Qt::PenStyle style);
47
48 Qt::PenStyle style() const;
49 void setStyle(Qt::PenStyle);
50
51 QList<qreal> dashPattern() const;
52 void setDashPattern(const QList<qreal> &pattern);
53
54 qreal dashOffset() const;
55 void setDashOffset(qreal doffset);
56
57 qreal miterLimit() const;
58 void setMiterLimit(qreal limit);
59
60 qreal widthF() const;
61 void setWidthF(qreal width);
62
63 int width() const;
64 void setWidth(int width);
65
66 QColor color() const;
67 void setColor(const QColor &color);
68
69 QBrush brush() const;
70 void setBrush(const QBrush &brush);
71
72 bool isSolid() const;
73
74 Qt::PenCapStyle capStyle() const;
75 void setCapStyle(Qt::PenCapStyle pcs);
76
77 Qt::PenJoinStyle joinStyle() const;
78 void setJoinStyle(Qt::PenJoinStyle pcs);
79
80 bool isCosmetic() const;
81 void setCosmetic(bool cosmetic);
82
83 bool operator==(const QPen &p) const;
84 inline bool operator!=(const QPen &p) const { return !(operator==(p)); }
85 operator QVariant() const;
86
87 bool isDetached();
88
89private:
90 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
91 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
92
93 bool isSolidDefaultLine() const noexcept;
94
95 bool doCompareEqualColor(QColor rhs) const noexcept;
96 friend bool comparesEqual(const QPen &lhs, QColor rhs) noexcept
97 {
98 return lhs.doCompareEqualColor(rhs);
99 }
100 Q_DECLARE_EQUALITY_COMPARABLE(QPen, QColor)
101
102 bool doCompareEqualStyle(Qt::PenStyle rhs) const;
103 friend bool comparesEqual(const QPen &lhs, Qt::PenStyle rhs)
104 {
105 return lhs.doCompareEqualStyle(rhs);
106 }
107 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QPen, Qt::PenStyle)
108
109public:
110 using DataPtr = QExplicitlySharedDataPointer<QPenPrivate>;
111
112private:
113 void detach();
114 DataPtr d;
115
116public:
117 inline DataPtr &data_ptr() { return d; }
118};
119
121
122#ifndef QT_NO_DEBUG_STREAM
123Q_GUI_EXPORT QDebug operator<<(QDebug, const QPen &);
124#endif
125
126QT_END_NAMESPACE
127
128#endif // QPEN_H
\inmodule QtGui
Definition qbrush.h:30
\inmodule QtGui
Definition qbrush.h:469
\inmodule QtCore\reentrant
Definition qdatastream.h:50
\inmodule QtGui
Definition qbrush.h:158
\inmodule QtGui
Definition qbrush.h:417
\inmodule QtGui
Definition qpen.h:29
\inmodule QtGui
Definition qbrush.h:435
Combined button and popup list for selecting options.
QList< QGradientStop > QGradientStops
Definition qbrush.h:155
std::pair< qreal, QColor > QGradientStop
Definition qbrush.h:154
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2582
void qRegisterGuiVariant()
void operator()(QBrushData *d) const noexcept
Definition qbrush.cpp:251
Qt::BrushStyle style
Definition qbrush.h:135
QBrushData()=default
QTransform transform
Definition qbrush.h:137
QAtomicInt ref
Definition qbrush.h:134
QColor color
Definition qbrush.h:136
static const QtPrivate::QMetaTypeInterface * interfaceForType(int type)
static bool convert(const void *from, int fromTypeId, void *to, int toTypeId)