- Qt 6.12
- Qt Canvas Painter
- C++ Classes
- QCanvasBrush
- Qt Canvas Painter | Commercial or GPLv3

# QCanvasBrush Class

QCanvasBrush is the base class for all QCanvasPainter fill / stroke brushes. More...

Header: | `#include <QCanvasBrush>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS CanvasPainter)` `target_link_libraries(mytarget PRIVATE Qt6::CanvasPainter)`
Since: | Qt 6.11

- List of all members, including inherited members

## Public Types

enum class | BrushType { Invalid, LinearGradient, RadialGradient, ConicalGradient, BoxGradient, …, Custom }

## Public Functions

| QCanvasBrush()
| QCanvasBrush(QCanvasImage &&other)
| QCanvasBrush(const QCanvasBrush &brush)
| QCanvasBrush(QCanvasBrush &&other)
void | swap(QCanvasBrush &other)
QCanvasBrush::BrushType | type() const
QCanvasBrush & | operator=(QCanvasBrush &&other)
QCanvasBrush & | operator=(const QCanvasBrush &brush)

## Related Non-Members

bool | operator!=(const QCanvasBrush &lhs, const QCanvasBrush &rhs)
bool | operator==(const QCanvasBrush &lhs, const QCanvasBrush &rhs)

## Detailed Description

QCanvasBrush is the base class for all styles used for QCanvasPainter::fill() and QCanvasPainter::stroke().

## Member Type Documentation

### enum class QCanvasBrush::BrushType

Specifies the type of brush.

Constant | Value | Description
--- | --- | ---
`QCanvasBrush::BrushType::Invalid` | `0` | - Empty brush.
`QCanvasBrush::BrushType::LinearGradient` | `1` | - Interpolates colors between start and end points (QCanvasLinearGradient)
`QCanvasBrush::BrushType::RadialGradient` | `2` | - Interpolates colors between a focal point and end points on a circle surrounding it (QCanvasRadialGradient).
`QCanvasBrush::BrushType::ConicalGradient` | `3` | - Interpolates colors around a center point (QCanvasConicalGradient).
`QCanvasBrush::BrushType::BoxGradient` | `4` | - Interpolates colors on a round rectangle (QCanvasBoxGradient).
`QCanvasBrush::BrushType::BoxShadow` | `5` | - Creates a soft round rectangle shadow (QCanvasBoxShadow).
`QCanvasBrush::BrushType::ImagePattern` | `6` | - Creates a pattern using the specified image and repetition (QCanvasImagePattern).
`QCanvasBrush::BrushType::GridPattern` | `7` | - Creates a pattern using the specified grid (QCanvasGridPattern).
`QCanvasBrush::BrushType::Custom` | `1000` | - Creates a custom shader brush (QCanvasCustomBrush).

See also type().

## Member Function Documentation

### QCanvasBrush::QCanvasBrush()

Constructs an invalid brush.

### `[noexcept implicit]` QCanvasBrush::QCanvasBrush(QCanvasImage &&other)

Move-constructs a new QCanvasBrush from other.

### QCanvasBrush::QCanvasBrush(const QCanvasBrush &brush)

Constructs a brush that is a copy of the given brush.

### `[constexpr noexcept default]` QCanvasBrush::QCanvasBrush(QCanvasBrush &&other)

Move-constructs an instance of QCanvasBrush.

### `[noexcept]` void QCanvasBrush::swap(QCanvasBrush &other)

Swaps this brush with other. This operation is very fast and never fails.

### QCanvasBrush::BrushType QCanvasBrush::type() const

Returns the type of the brush.

### `[noexcept]` QCanvasBrush &QCanvasBrush::operator=(QCanvasBrush &&other)

Move-assigns other to this QCanvasBrush instance.

### QCanvasBrush &QCanvasBrush::operator=(const QCanvasBrush &brush)

Assigns the given brush to this brush and returns a reference to this brush.

## Related Non-Members

### `[noexcept]` bool operator!=(const QCanvasBrush &lhs, const QCanvasBrush &rhs)

Returns `true` if the brush lhs is different from rhs; `false` otherwise.

See also operator==().

### `[noexcept]` bool operator==(const QCanvasBrush &lhs, const QCanvasBrush &rhs)

Returns `true` if the brush lhs is equal to rhs; `false` otherwise.

Brushes are compared by value, and comparing two QCanvasBrush gives the same result as comparing the concrete brushes (e.g., QCanvasGridPattern) they were created from.

See also operator!=().