File indexing completed on 2025-10-30 08:51:24
0001
0002
0003
0004 #ifndef QPEN_H
0005 #define QPEN_H
0006
0007 #include <QtCore/qshareddata.h>
0008 #include <QtGui/qtguiglobal.h>
0009 #include <QtGui/qcolor.h>
0010 #include <QtGui/qbrush.h>
0011
0012 QT_BEGIN_NAMESPACE
0013
0014
0015 class QVariant;
0016 class QPenPrivate;
0017 class QBrush;
0018 class QPen;
0019
0020 #ifndef QT_NO_DATASTREAM
0021 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
0022 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
0023 #endif
0024
0025 QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QPenPrivate, Q_GUI_EXPORT)
0026
0027 class Q_GUI_EXPORT QPen
0028 {
0029 public:
0030 QPen();
0031 QPen(Qt::PenStyle);
0032 QPen(const QColor &color);
0033 QPen(const QBrush &brush, qreal width, Qt::PenStyle s = Qt::SolidLine,
0034 Qt::PenCapStyle c = Qt::SquareCap, Qt::PenJoinStyle j = Qt::BevelJoin);
0035 QPen(const QPen &pen) noexcept;
0036
0037 ~QPen();
0038
0039 QPen &operator=(const QPen &pen) noexcept;
0040 QPen(QPen &&other) noexcept = default;
0041 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPen)
0042 void swap(QPen &other) noexcept { d.swap(other.d); }
0043
0044 QPen &operator=(QColor color);
0045 QPen &operator=(Qt::PenStyle style);
0046
0047 Qt::PenStyle style() const;
0048 void setStyle(Qt::PenStyle);
0049
0050 QList<qreal> dashPattern() const;
0051 void setDashPattern(const QList<qreal> &pattern);
0052
0053 qreal dashOffset() const;
0054 void setDashOffset(qreal doffset);
0055
0056 qreal miterLimit() const;
0057 void setMiterLimit(qreal limit);
0058
0059 qreal widthF() const;
0060 void setWidthF(qreal width);
0061
0062 int width() const;
0063 void setWidth(int width);
0064
0065 QColor color() const;
0066 void setColor(const QColor &color);
0067
0068 QBrush brush() const;
0069 void setBrush(const QBrush &brush);
0070
0071 bool isSolid() const;
0072
0073 Qt::PenCapStyle capStyle() const;
0074 void setCapStyle(Qt::PenCapStyle pcs);
0075
0076 Qt::PenJoinStyle joinStyle() const;
0077 void setJoinStyle(Qt::PenJoinStyle pcs);
0078
0079 bool isCosmetic() const;
0080 void setCosmetic(bool cosmetic);
0081
0082 bool operator==(const QPen &p) const;
0083 inline bool operator!=(const QPen &p) const { return !(operator==(p)); }
0084 operator QVariant() const;
0085
0086 bool isDetached();
0087
0088 private:
0089 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
0090 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
0091
0092 bool isSolidDefaultLine() const noexcept;
0093
0094 bool doCompareEqualColor(QColor rhs) const noexcept;
0095 friend bool comparesEqual(const QPen &lhs, QColor rhs) noexcept
0096 {
0097 return lhs.doCompareEqualColor(rhs);
0098 }
0099 Q_DECLARE_EQUALITY_COMPARABLE(QPen, QColor)
0100
0101 bool doCompareEqualStyle(Qt::PenStyle rhs) const;
0102 friend bool comparesEqual(const QPen &lhs, Qt::PenStyle rhs)
0103 {
0104 return lhs.doCompareEqualStyle(rhs);
0105 }
0106 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QPen, Qt::PenStyle)
0107
0108 public:
0109 using DataPtr = QExplicitlySharedDataPointer<QPenPrivate>;
0110
0111 private:
0112 void detach();
0113 DataPtr d;
0114
0115 public:
0116 inline DataPtr &data_ptr() { return d; }
0117 };
0118
0119 Q_DECLARE_SHARED(QPen)
0120
0121 #ifndef QT_NO_DEBUG_STREAM
0122 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPen &);
0123 #endif
0124
0125 QT_END_NAMESPACE
0126
0127 #endif