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