Qt 4.8
Public Functions | List of all members
QLinearGradient Class Reference

The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush. More...

#include <qbrush.h>

Inheritance diagram for QLinearGradient:
QGradient

Public Functions

QPointF finalStop () const
 Returns the final stop point of this linear gradient in logical coordinates. More...
 
 QLinearGradient ()
 Constructs a default linear gradient with interpolation area between (0, 0) and (1, 1). More...
 
 QLinearGradient (const QPointF &start, const QPointF &finalStop)
 Constructs a linear gradient with interpolation area between the given start point and finalStop. More...
 
 QLinearGradient (qreal xStart, qreal yStart, qreal xFinalStop, qreal yFinalStop)
 Constructs a linear gradient with interpolation area between (x1, y1) and (x2, y2). More...
 
void setFinalStop (const QPointF &stop)
 Sets the final stop point of this linear gradient in logical coordinates to stop. More...
 
void setFinalStop (qreal x, qreal y)
 Sets the final stop point of this linear gradient in logical coordinates to x, y. More...
 
void setStart (const QPointF &start)
 Sets the start point of this linear gradient in logical coordinates to start. More...
 
void setStart (qreal x, qreal y)
 Sets the start point of this linear gradient in logical coordinates to x, y. More...
 
QPointF start () const
 Returns the start point of this linear gradient in logical coordinates. More...
 
- Public Functions inherited from QGradient
CoordinateMode coordinateMode () const
 Returns the coordinate mode of this gradient. More...
 
InterpolationMode interpolationMode () const
 Returns the interpolation mode of this gradient. More...
 
bool operator!= (const QGradient &other) const
 Returns true if the gradient is the same as the other gradient specified; otherwise returns false. More...
 
bool operator== (const QGradient &gradient) const
 Returns true if the gradient is the same as the other gradient specified; otherwise returns false. More...
 
bool operator== (const QGradient &gradient)
 
 QGradient ()
 
void setColorAt (qreal pos, const QColor &color)
 Creates a stop point at the given position with the given color. More...
 
void setCoordinateMode (CoordinateMode mode)
 Sets the coordinate mode of this gradient to mode. More...
 
void setInterpolationMode (InterpolationMode mode)
 Sets the interpolation mode of this gradient to mode. More...
 
void setSpread (Spread spread)
 Specifies the spread method that should be used for this gradient. More...
 
void setStops (const QGradientStops &stops)
 Replaces the current set of stop points with the given stopPoints. More...
 
Spread spread () const
 Returns the spread method use by this gradient. More...
 
QGradientStops stops () const
 Returns the stop points for this gradient. More...
 
Type type () const
 Returns the type of gradient. More...
 

Additional Inherited Members

- Public Types inherited from QGradient
enum  CoordinateMode { LogicalMode, StretchToDeviceMode, ObjectBoundingMode }
 This enum specifies how gradient coordinates map to the paint device on which the gradient is used. More...
 
enum  InterpolationMode { ColorInterpolation, ComponentInterpolation }
 
enum  Spread { PadSpread, ReflectSpread, RepeatSpread }
 Specifies how the area outside the gradient area should be filled. More...
 
enum  Type { LinearGradient, RadialGradient, ConicalGradient, NoGradient }
 Specifies the type of gradient. More...
 

Detailed Description

The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush.

Linear gradients interpolate colors between start and end points. Outside these points the gradient is either padded, reflected or repeated depending on the currently set QGradient::Spread method:

qlineargradient-pad.png
qlineargradient-reflect.png
qlineargradient-repeat.png
QGradient::PadSpread{PadSpread} (default) QGradient::ReflectSpread{ReflectSpread} QGradient::RepeatSpread{RepeatSpread}

The colors in a gradient is defined using stop points of the QGradientStop type, i.e. a position and a color. Use the QGradient::setColorAt() or the QGradient::setStops() function to define the stop points. It is the gradient's complete set of stop points that describes how the gradient area should be filled. If no stop points have been specified, a gradient of black at 0 to white at 1 is used.

In addition to the functions inherited from QGradient, the QLinearGradient class provides the finalStop() function which returns the final stop point of the gradient, and the start() function returning the start point of the gradient.

See also
QRadialGradient, QConicalGradient, {demos/gradients}{The Gradients Demo}

Definition at line 280 of file qbrush.h.

Constructors and Destructors

◆ QLinearGradient() [1/3]

QLinearGradient::QLinearGradient ( )

Constructs a default linear gradient with interpolation area between (0, 0) and (1, 1).

See also
QGradient::setColorAt(), setStart(), setFinalStop()

Definition at line 1737 of file qbrush.cpp.

1738 {
1740  m_spread = PadSpread;
1741  m_data.linear.x1 = 0;
1742  m_data.linear.y1 = 0;
1743  m_data.linear.x2 = 1;
1744  m_data.linear.y2 = 1;
1745 }
Type m_type
Definition: qbrush.h:260
union QGradient::@216 m_data
Spread m_spread
Definition: qbrush.h:261

◆ QLinearGradient() [2/3]

QLinearGradient::QLinearGradient ( const QPointF start,
const QPointF finalStop 
)

Constructs a linear gradient with interpolation area between the given start point and finalStop.

Note
The expected parameter values are in pixels.
See also
QGradient::setColorAt(), QGradient::setStops()

Definition at line 1756 of file qbrush.cpp.

1757 {
1759  m_spread = PadSpread;
1760  m_data.linear.x1 = start.x();
1761  m_data.linear.y1 = start.y();
1762  m_data.linear.x2 = finalStop.x();
1763  m_data.linear.y2 = finalStop.y();
1764 }
Type m_type
Definition: qbrush.h:260
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
union QGradient::@216 m_data
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
Spread m_spread
Definition: qbrush.h:261

◆ QLinearGradient() [3/3]

QLinearGradient::QLinearGradient ( qreal  x1,
qreal  y1,
qreal  x2,
qreal  y2 
)

Constructs a linear gradient with interpolation area between (x1, y1) and (x2, y2).

Note
The expected parameter values are in pixels.
See also
QGradient::setColorAt(), QGradient::setStops()

Definition at line 1779 of file qbrush.cpp.

1780 {
1782  m_spread = PadSpread;
1783  m_data.linear.x1 = xStart;
1784  m_data.linear.y1 = yStart;
1785  m_data.linear.x2 = xFinalStop;
1786  m_data.linear.y2 = yFinalStop;
1787 }
Type m_type
Definition: qbrush.h:260
union QGradient::@216 m_data
Spread m_spread
Definition: qbrush.h:261

Functions

◆ finalStop()

QPointF QLinearGradient::finalStop ( ) const

Returns the final stop point of this linear gradient in logical coordinates.

See also
QGradient::stops()

Definition at line 1856 of file qbrush.cpp.

Referenced by QPdf::patternForBrush(), QSvgPaintEngine::saveLinearGradientBrush(), QCoreGraphicsPaintEnginePrivate::setFillBrush(), QSpanData::setup(), QGL2PaintEngineExPrivate::updateBrushUniforms(), and QOpenGLPaintEnginePrivate::updateGradient().

1857 {
1859  return QPointF(m_data.linear.x2, m_data.linear.y2);
1860 }
Type m_type
Definition: qbrush.h:260
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
union QGradient::@216 m_data

◆ setFinalStop() [1/2]

void QLinearGradient::setFinalStop ( const QPointF stop)

Sets the final stop point of this linear gradient in logical coordinates to stop.

Since
4.2
See also
finalStop()

Definition at line 1875 of file qbrush.cpp.

Referenced by QCleanlooksStyle::drawComplexControl().

1876 {
1878  m_data.linear.x2 = stop.x();
1879  m_data.linear.y2 = stop.y();
1880 }
Type m_type
Definition: qbrush.h:260
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
union QGradient::@216 m_data
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287

◆ setFinalStop() [2/2]

void QLinearGradient::setFinalStop ( qreal  x,
qreal  y 
)
inline

Sets the final stop point of this linear gradient in logical coordinates to x, y.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
4.2
See also
start()

Definition at line 293 of file qbrush.h.

Referenced by setFinalStop().

293 { setFinalStop(QPointF(x, y)); }
void setFinalStop(const QPointF &stop)
Sets the final stop point of this linear gradient in logical coordinates to stop. ...
Definition: qbrush.cpp:1875
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214

◆ setStart() [1/2]

void QLinearGradient::setStart ( const QPointF start)

Sets the start point of this linear gradient in logical coordinates to start.

Since
4.2
See also
start()

Definition at line 1828 of file qbrush.cpp.

Referenced by QCleanlooksStyle::drawComplexControl().

1829 {
1831  m_data.linear.x1 = start.x();
1832  m_data.linear.y1 = start.y();
1833 }
Type m_type
Definition: qbrush.h:260
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
union QGradient::@216 m_data
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287

◆ setStart() [2/2]

void QLinearGradient::setStart ( qreal  x,
qreal  y 
)
inline

Sets the start point of this linear gradient in logical coordinates to x, y.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
4.2
See also
start()

Definition at line 289 of file qbrush.h.

Referenced by setStart().

289 { setStart(QPointF(x, y)); }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void setStart(const QPointF &start)
Sets the start point of this linear gradient in logical coordinates to start.
Definition: qbrush.cpp:1828

◆ start()

QPointF QLinearGradient::start ( ) const

Returns the start point of this linear gradient in logical coordinates.

See also
QGradient::stops()

Definition at line 1796 of file qbrush.cpp.

Referenced by QPdf::patternForBrush(), QSvgPaintEngine::saveLinearGradientBrush(), QVGPaintEnginePrivate::setBrush(), QCoreGraphicsPaintEnginePrivate::setFillBrush(), QSpanData::setup(), QGL2PaintEngineExPrivate::updateBrushUniforms(), and QOpenGLPaintEnginePrivate::updateGradient().

1797 {
1799  return QPointF(m_data.linear.x1, m_data.linear.y1);
1800 }
Type m_type
Definition: qbrush.h:260
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
union QGradient::@216 m_data

The documentation for this class was generated from the following files: