QtBase  v6.3.1
qpen.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QPEN_H
41 #define QPEN_H
42 
43 #include <QtGui/qtguiglobal.h>
44 #include <QtGui/qcolor.h>
45 #include <QtGui/qbrush.h>
46 
48 
49 
50 class QVariant;
51 class QPenPrivate;
52 class QBrush;
53 class QPen;
54 
55 #ifndef QT_NO_DATASTREAM
56 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
57 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
58 #endif
59 
60 class Q_GUI_EXPORT QPen
61 {
62 public:
63  QPen();
65  QPen(const QColor &color);
68  QPen(const QPen &pen) noexcept;
69 
70  ~QPen();
71 
72  QPen &operator=(const QPen &pen) noexcept;
73  QPen(QPen &&other) noexcept
74  : d(qExchange(other.d, nullptr)) {}
76  void swap(QPen &other) noexcept { qt_ptr_swap(d, other.d); }
77 
78  Qt::PenStyle style() const;
79  void setStyle(Qt::PenStyle);
80 
81  QList<qreal> dashPattern() const;
82  void setDashPattern(const QList<qreal> &pattern);
83 
84  qreal dashOffset() const;
85  void setDashOffset(qreal doffset);
86 
87  qreal miterLimit() const;
88  void setMiterLimit(qreal limit);
89 
90  qreal widthF() const;
91  void setWidthF(qreal width);
92 
93  int width() const;
94  void setWidth(int width);
95 
96  QColor color() const;
97  void setColor(const QColor &color);
98 
99  QBrush brush() const;
100  void setBrush(const QBrush &brush);
101 
102  bool isSolid() const;
103 
104  Qt::PenCapStyle capStyle() const;
105  void setCapStyle(Qt::PenCapStyle pcs);
106 
107  Qt::PenJoinStyle joinStyle() const;
108  void setJoinStyle(Qt::PenJoinStyle pcs);
109 
110  bool isCosmetic() const;
111  void setCosmetic(bool cosmetic);
112 
113  bool operator==(const QPen &p) const;
114  inline bool operator!=(const QPen &p) const { return !(operator==(p)); }
115  operator QVariant() const;
116 
117  bool isDetached();
118 private:
119  friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
120  friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
121 
122  void detach();
123  class QPenPrivate *d;
124 
125 public:
126  typedef QPenPrivate * DataPtr;
127  inline DataPtr &data_ptr() { return d; }
128 };
129 
131 
132 #ifndef QT_NO_DEBUG_STREAM
133 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPen &);
134 #endif
135 
137 
138 #endif // QPEN_H
Arabic default style
Definition: afstyles.h:94
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:66
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:66
operator>>(QDataStream &ds, qfloat16 &f)
Definition: qfloat16.cpp:344
operator<<(QDataStream &ds, qfloat16 f)
Definition: qfloat16.cpp:327
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:65
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:61
QPen(QPen &&other) noexcept
Definition: qpen.h:73
DataPtr & data_ptr()
Definition: qpen.h:127
bool operator!=(const QPen &p) const
Definition: qpen.h:114
QPenPrivate * DataPtr
Definition: qpen.h:126
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:95
PenStyle
Definition: qnamespace.h:1111
@ SolidLine
Definition: qnamespace.h:1113
PenJoinStyle
Definition: qnamespace.h:1131
@ BevelJoin
Definition: qnamespace.h:1133
PenCapStyle
Definition: qnamespace.h:1124
@ SquareCap
Definition: qnamespace.h:1126
Definition: brush.cpp:52
void
Definition: png.h:1080
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(Class)
Definition: qglobal.h:563
bool operator==(const QMakeBaseKey &one, const QMakeBaseKey &two)
GLint GLsizei width
GLuint color
[2]
const GLubyte * c
Definition: qopenglext.h:12701
GLint limit
Definition: qopenglext.h:9975
GLdouble s
[6]
Definition: qopenglext.h:235
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
GLubyte * pattern
Definition: qopenglext.h:2744
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QPen &)
Definition: qpen.cpp:954
Q_GUI_EXPORT QDataStream & operator<<(QDataStream &, const QPen &)
Definition: qpen.cpp:906
#define Q_DECLARE_SHARED(TYPE)
Definition: qtypeinfo.h:197
QSharedPointer< T > other(t)
[5]
this swap(other)
myFilter setColor(QColor(128, 0, 0))
widget setStyle(proxy)