C
Qul::PaintedItemDelegate Class
class Qul::PaintedItemDelegate用于表示绘制项对象的基类。更多...
| Header: | #include <qul/painteditemdelegate.h> |
| Since: | Qt Quick Ultralite 1.9 |
| Inherits: | Qul::Object |
公共函数
| virtual Qul::PlatformInterface::Rect | boundingRect(Qul::PlatformInterface::Size size) const = 0 |
| virtual void | paint(Qul::PlatformInterface::DrawingDevice *device, const Qul::PlatformInterface::Rect &clip, const Qul::PlatformInterface::Transform &transform, Qul::PlatformInterface::Size size, float opacity) const = 0 |
| void | update() const |
| void | update(int x, int y, int width, int height) const |
详细说明
自定义绘制项对象可以从 PaintedItemDelegate 类派生。派生类必须实现纯虚方法paint(),以便使用平台上下文或直接操作帧缓冲区的像素进行绘制。
class CustomPaintedItemDelegate : public Qul::PaintedItemDelegate { public: Qul::Property<int> scale; Qul::Property<Qul::Private::Matrix4x4> transform; Qul::PlatformInterface::Rect boundingRect(Qul::PlatformInterface::Size size) const override; void paint(Qul::PlatformInterface::DrawingDevice *device, const Qul::PlatformInterface::Rect &clip, const Qul::PlatformInterface::Transform &transform, Qul::PlatformInterface::Size size, float opacity) const override; void paintCircle(Qul::PlatformInterface::DrawingDevice *device, const Qul::PlatformInterface::Rect &clip, Qul::PlatformInterface::Point center, int radius, Qul::PlatformInterface::Rgba32 color) const; };
在之前的示例中,CustomPaintedItemDelegate类继承自PaintedItemDelegate。其paint 方法的实现使用从Qul::PlatformInterface::DrawingDevice 的*device参数中获取的平台上下文或帧缓冲区地址。
QPainter *painter = static_cast<QPainter *>(device->platformContext());
另请参阅 PaintedItem 。
成员函数文档
[pure virtual] Qul::PlatformInterface::Rect PaintedItemDelegate::boundingRect(Qul::PlatformInterface::Size size) const
返回将在 paint 方法中使用的有界矩形。
它返回一个 Rectangle 对象,其宽度和高度由size 定义。
另请参阅 paint 。
[pure virtual] void PaintedItemDelegate::paint(Qul::PlatformInterface::DrawingDevice *device, const Qul::PlatformInterface::Rect &clip, const Qul::PlatformInterface::Transform &transform, Qul::PlatformInterface::Size size, float opacity) const
更新绘制对象。
每当应用程序触发更新事件时,都会调用此方法。
device 参数包含帧缓冲区地址、bytesPerPixel和bytesPerLine,这些是软件渲染所必需的。如果存在platformContext,可以获取它以访问特定于平台的硬件渲染能力。
如果绘制项位于另一个项内部或处于部分更新状态,则可将混合效果限制在由 `clip` 定义的区域内。
size 可用于获取与绘制项大小相等的边界矩形。
该方法还可以应用 Qml 应用程序中定义的transform 。
关于绘制项不透明度的信息由opacity 参数提供。
void PaintedItemDelegate::update() const
更新已绘制项。
每当绘制项需要更新时,应用程序都会调用此方法。它会遍历与该绘制项关联的节点,并触发对已修改节点的重绘。
另请参阅 paint 。
void PaintedItemDelegate::update(int x, int y, int width, int height) const
使用指定的边界区域更新绘制项。
此方法仅触发指定区域内绘制项的重新绘制。该区域由该项的x 、y 、width 和height 属性定义。
另请参阅 paint 。
在某些 Qt 许可证下可用。
了解更多信息。