QCGradient Class
QCGradient is the base class for all QCPainter gradient brushes. More...
| Header: | #include <QCGradient> |
| Inherits: | QCBrush |
| Inherited By: | QCBoxGradient, QCConicalGradient, QCLinearGradient, and QCRadialGradient |
Public Functions
| QCGradient(QCBrush::BrushType type) | |
| QCGradient(const QCGradient &gradient) | |
| QCGradient(QCGradient &&other) | |
| virtual | ~QCGradient() |
| QColor | endColor() const |
| void | setColorAt(float position, const QColor &color) |
| void | setEndColor(const QColor &color) |
| void | setStartColor(const QColor &color) |
| void | setStops(const QCGradientStops &stops) |
| QColor | startColor() const |
| QCGradientStops | stops() const |
| void | swap(QCGradient &other) |
| QVariant | operator QVariant() const |
| bool | operator!=(const QCGradient &gradient) const |
| QCGradient & | operator=(QCGradient &&other) |
| QCGradient & | operator=(const QCGradient &gradient) |
| bool | operator==(const QCGradient &gradient) const |
Reimplemented Public Functions
| virtual QCBrush::BrushType | type() const override |
Related Non-Members
| QCGradientStop | |
| QCGradientStops | |
| QDataStream & | operator<<(QDataStream &stream, const QCGradient &gradient) |
| QDataStream & | operator>>(QDataStream &stream, QCGradient &gradient) |
Detailed Description
QCGradient is the base class for all QCPainter gradient brushes. Currently there are four type of gradients: QCLinearGradient, QCRadialGradient, QCConicalGradient and QCBoxGradient.
If no stops are provided with setStartColor, setEndColor, setColorAt or setStops, the gragient is rendered as start color white (255,255,255) and end color transparent (0,0,0,0). If only a single stop is provided, the gradient is filled with this color.
Member Function Documentation
QCGradient::QCGradient(QCBrush::BrushType type)
Constructs a default gradient of type type.
[noexcept] QCGradient::QCGradient(const QCGradient &gradient)
Constructs a gradient that is a copy of the given gradient.
[constexpr noexcept] QCGradient::QCGradient(QCGradient &&other)
Move-constructs a new QCGradient from other.
[virtual noexcept] QCGradient::~QCGradient()
Destroys the gradient.
QColor QCGradient::endColor() const
Returns the gradient end color or the color at the largest position. If the end color has not been set, returns the default end color transparent black (0, 0, 0, 0).
See also setEndColor().
void QCGradient::setColorAt(float position, const QColor &color)
Creates a stop point at the given position with the given color. The given position must be in the range 0 to 1.
See also setStops() and stops().
void QCGradient::setEndColor(const QColor &color)
Sets the end color of gradient to color. This is equal to calling setColorAt() with position 1.
See also endColor().
void QCGradient::setStartColor(const QColor &color)
Sets the start color of gradient to color. This is equal to calling setColorAt() with position 0.
See also startColor().
void QCGradient::setStops(const QCGradientStops &stops)
Replaces the current set of stop points with the given stops.
The rules for the stops list are following:
- The list should contain at least 2 stops.
- The positions of the stops must be in the range 0 to 1, and must be sorted with the lowest stops first.
- The first position must be at 0.0 and the last position at 1.0.
See also setColorAt() and stops().
QColor QCGradient::startColor() const
Returns the gradient start color or the color at the smallest position. If the start color has not been set, returns the default start color white (255, 255, 255).
See also setStartColor().
QCGradientStops QCGradient::stops() const
Returns the stop points for this gradient.
See also setStops() and setColorAt().
[noexcept] void QCGradient::swap(QCGradient &other)
Swaps this gradient with other. This operation is very fast and never fails.
[override virtual] QCBrush::BrushType QCGradient::type() const
Reimplements: QCBrush::type() const.
Returns the type of gradient.
QVariant QCGradient::operator QVariant() const
Returns the gradient as a QVariant.
bool QCGradient::operator!=(const QCGradient &gradient) const
Returns true if the gradient is different from the given gradient; otherwise false.
See also operator==().
[noexcept] QCGradient &QCGradient::operator=(QCGradient &&other)
Move-assigns other to this QCGradient instance.
[noexcept] QCGradient &QCGradient::operator=(const QCGradient &gradient)
Assigns the given gradient to this gradient and returns a reference to this gradient.
bool QCGradient::operator==(const QCGradient &gradient) const
Returns true if the gradient is equal to the given gradient; otherwise false.
See also operator!=().
Related Non-Members
QCGradientStop
Typedef for std::pair<float, QColor>.
QCGradientStops
Typedef for QList<QCGradientStop>.
QDataStream &operator<<(QDataStream &stream, const QCGradient &gradient)
Writes the given gradient to the given stream and returns a reference to the stream.
See also Serializing Qt Data Types.
QDataStream &operator>>(QDataStream &stream, QCGradient &gradient)
Reads the given gradient from the given stream and returns a reference to the stream.
See also Serializing Qt Data Types.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.