本页内容

QCanvasBrush Class

QCanvasBrush 是所有QCanvasPainter 填充/描边画笔的基类。更多内容...

标题: #include <QCanvasBrush>
CMake: find_package(Qt6 REQUIRED COMPONENTS CanvasPainter)
target_link_libraries(mytarget PRIVATE Qt6::CanvasPainter)
自: Qt 6.11

公共类型

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

公共函数

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)
bool operator!=(const QCanvasBrush &lhs, const QCanvasBrush &rhs)
bool operator==(const QCanvasBrush &lhs, const QCanvasBrush &rhs)

详细说明

QCanvasBrush 是用于 `QCanvasPainter::fill()` 和 `QCanvasPainter::stroke()` 的所有样式的基类。

成员类型文档

enum class QCanvasBrush::BrushType

指定画笔的类型。

常量值描述
QCanvasBrush::BrushType::Invalid0- 空画笔。
QCanvasBrush::BrushType::LinearGradient1- 对起始点和终点之间的颜色进行插值(QCanvasLinearGradient )
QCanvasBrush::BrushType::RadialGradient2- 对围绕焦点的圆上,焦点与端点之间的颜色进行插值(QCanvasRadialGradient )。
QCanvasBrush::BrushType::ConicalGradient3- 围绕中心点进行颜色插值(QCanvasConicalGradient )。
QCanvasBrush::BrushType::BoxGradient4- 在圆角矩形上进行颜色插值(QCanvasBoxGradient )。
QCanvasBrush::BrushType::BoxShadow5- 生成柔和的圆角矩形阴影(QCanvasBoxShadow )。
QCanvasBrush::BrushType::ImagePattern6- 使用指定的图像和重复模式创建图案(QCanvasImagePattern )。
QCanvasBrush::BrushType::GridPattern7- 使用指定的网格创建图案(QCanvasGridPattern )。
QCanvasBrush::BrushType::Custom1000- 创建自定义着色器画笔(QCanvasCustomBrush )。

另请参阅 type()。

成员函数文档

QCanvasBrush::QCanvasBrush()

创建了一个无效的画笔。

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

从other 创建一个新的QCanvasBrush对象。

QCanvasBrush::QCanvasBrush(const QCanvasBrush &brush)

创建一个画笔,该画笔是给定brush 的副本。

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

通过“Move”操作构造一个QCanvasBrush 实例。

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

将此画笔替换为other 。此操作非常快速,且从未失败。

QCanvasBrush::BrushType QCanvasBrush::type() const

返回画笔的类型。

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

将other 通过move-assign操作赋值给此QCanvasBrush 实例。

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

将给定的brush 分配给此画笔,并返回对此画笔的引用。

相关的非成员

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

如果画笔lhs 与rhs 不同,则返回true ;否则返回false 。

另请参阅 operator==()。

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

如果画笔lhs 等于rhs ,则返回true ;否则返回false 。

画笔按值进行比较,比较两个QCanvasBrush 的结果与比较其所创建的具体画笔(例如QCanvasGridPattern )的结果相同。

另请参阅 operator!=()。

© 2026 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.