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
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
26
27class Q_GUI_EXPORT QPen
28{
29public:
30 QPen();
32 QPen(const QColor &color);
35 QPen(const QPen &pen) noexcept;
36
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 Qt::PenStyle style() const;
46
47 QList<qreal> dashPattern() const;
48 void setDashPattern(const QList<qreal> &pattern);
49
50 qreal dashOffset() const;
51 void setDashOffset(qreal doffset);
52
53 qreal miterLimit() const;
55
56 qreal widthF() const;
57 void setWidthF(qreal width);
58
59 int width() const;
60 void setWidth(int width);
61
62 QColor color() const;
63 void setColor(const QColor &color);
64
65 QBrush brush() const;
66 void setBrush(const QBrush &brush);
67
68 bool isSolid() const;
69
72
75
76 bool isCosmetic() const;
77 void setCosmetic(bool cosmetic);
78
79 bool operator==(const QPen &p) const;
80 inline bool operator!=(const QPen &p) const { return !(operator==(p)); }
81 operator QVariant() const;
82
83 bool isDetached();
84
85private:
86 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
87 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
88
89public:
90 using DataPtr = QExplicitlySharedDataPointer<QPenPrivate>;
91
92private:
93 void detach();
94 DataPtr d;
95
96public:
97 inline DataPtr &data_ptr() { return d; }
98};
99
100Q_DECLARE_SHARED(QPen)
101
102#ifndef QT_NO_DEBUG_STREAM
103Q_GUI_EXPORT QDebug operator<<(QDebug, const QPen &);
104#endif
105
107
108#endif // QPEN_H
\inmodule QtGui
Definition qbrush.h:30
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore
\inmodule QtGui
Definition qpen.h:28
qreal widthF() const
Returns the pen width with floating point precision.
Definition qpen.cpp:572
QList< qreal > dashPattern() const
Returns the dash pattern of this pen.
Definition qpen.cpp:400
QPen()
Constructs a default black solid line pen with 1 width.
Definition qpen.cpp:228
bool isCosmetic() const
Returns true if the pen is cosmetic; otherwise returns false.
Definition qpen.cpp:757
void setWidth(int width)
Sets the pen width to the given width in pixels with integer precision.
Definition qpen.cpp:592
~QPen()
Destroys the pen.
void setWidthF(qreal width)
Sets the pen width to the given width in pixels with floating point precision.
Definition qpen.cpp:618
DataPtr & data_ptr()
Definition qpen.h:97
Qt::PenCapStyle capStyle() const
Returns the pen's cap style.
Definition qpen.cpp:636
void setBrush(const QBrush &brush)
Sets the brush used to fill strokes generated with this pen to the given brush.
Definition qpen.cpp:726
QPen(QPen &&other) noexcept=default
void setJoinStyle(Qt::PenJoinStyle pcs)
Sets the pen's join style to the given style.
Definition qpen.cpp:677
void setDashOffset(qreal doffset)
Sets the dash offset (the starting point on the dash pattern) for this pen to the offset specified.
Definition qpen.cpp:506
bool isDetached()
Definition qpen.cpp:820
bool operator!=(const QPen &p) const
Returns true if the pen is different from the given pen; otherwise false.
Definition qpen.h:80
void setMiterLimit(qreal limit)
Sets the miter limit of this pen to the given limit.
Definition qpen.cpp:545
QPen & operator=(const QPen &pen) noexcept
Assigns the given pen to this pen and returns a reference to this pen.
Definition qpen.cpp:329
bool isSolid() const
Returns true if the pen has a solid fill, otherwise false.
Definition qpen.cpp:738
Qt::PenJoinStyle joinStyle() const
Returns the pen's join style.
Definition qpen.cpp:663
void setCosmetic(bool cosmetic)
Sets this pen to cosmetic or non-cosmetic, depending on the value of cosmetic.
Definition qpen.cpp:770
void setDashPattern(const QList< qreal > &pattern)
Sets the dash pattern for this pen to the given pattern.
Definition qpen.cpp:463
qreal miterLimit() const
Returns the miter limit of the pen.
Definition qpen.cpp:524
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition qpen.cpp:715
qreal dashOffset() const
Returns the dash offset for the pen.
Definition qpen.cpp:484
Qt::PenStyle style() const
Returns the pen style.
Definition qpen.cpp:366
\inmodule QtCore
Definition qvariant.h:65
Combined button and popup list for selecting options.
@ SolidLine
PenJoinStyle
@ BevelJoin
PenCapStyle
@ SquareCap
Definition brush.cpp:5
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
GLint GLsizei width
GLuint color
[2]
GLdouble s
[6]
Definition qopenglext.h:235
const GLubyte * c
GLint limit
GLfloat GLfloat p
[1]
GLubyte * pattern
static void setCapStyle(int cap_style, GC gc)
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QPen &)
Definition qpen.cpp:887
Q_GUI_EXPORT QDataStream & operator<<(QDataStream &, const QPen &)
Definition qpen.cpp:840
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
#define QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(Class, ExportMacro)
double qreal
Definition qtypes.h:187
QSharedPointer< T > other(t)
[5]
this swap(other)
myFilter setColor(QColor(128, 0, 0))
widget setStyle(proxy)