PaintedItemDelegate Class

class Qul::PaintedItemDelegate

Base class for representing painted item objects. More...

Header: #include <qul/painteditemdelegate.h>
Since: Qt Quick Ultralite 1.9
Inherits: Qul::Object

Public Functions

virtual PlatformInterface::Rect boundingRect(PlatformInterface::Size size) const = 0
virtual void paint(PlatformInterface::DrawingDevice *device, const PlatformInterface::Rect &clip, const PlatformInterface::Transform &transform, PlatformInterface::Size size, float opacity) const = 0
void update()
void update(int x, int y, int width, int height)

Detailed Description

Custom painted item objects can be derived from the PaintedItemDelegate class. The derived class must implement the paint() pure virtual method, to draw using the platform context or direct pixel manipulation of framebuffer.

class CustomPaintedItemDelegate : public Qul::PaintedItemDelegate
    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,
                     Qul::PlatformInterface::Point center,
                     int radius,
                     Qul::PlatformInterface::Rgba32 color) const;

In the earlier example, the CustomPaintedItemDelegate class derives from PaintedItemDelegate. Its paint method implementation uses the platform context or framebuffer address obtained from Qul::PlatformInterface::DrawingDevice *device parameter.

QPainter *painter = static_cast<QPainter *>(device->platformContext());

See also PaintedItem.

Member Function Documentation

[pure virtual] PlatformInterface::Rect PaintedItemDelegate::boundingRect(PlatformInterface::Size size) const

Returns the bounded rectangle to be used in the paint method.

It returns a Rectangle object with the width and height defined by size.

See also paint.

[pure virtual] void PaintedItemDelegate::paint(PlatformInterface::DrawingDevice *device, const PlatformInterface::Rect &clip, const PlatformInterface::Transform &transform, PlatformInterface::Size size, float opacity) const

Updates the painted item.

This method is called whenever an update event is triggered from the application.

The device parameter includes, fraembuffer address, bytesPerPixel, and bytesPerLine required for software-based rendering. If a platformContext is available, it can be obtained to access the platform-specific hardware capabilities to render.

Blending can be restricted to the area defined by clip, if the painted item is inside another item or on partial update.

size can be used to get bounding rectangle equal to size of the painted item.

This method can also apply transform as defined in the Qml Application.

Information about the opacity of the painteditem is given by opacity parameter.

void PaintedItemDelegate::update()

Updates the painted item.

This method is called by the application whenever the painted item requires an update. It traverses the nodes associated with the painted item and triggers a redraw for the dirty nodes.

See also paint.

void PaintedItemDelegate::update(int x, int y, int width, int height)

Updates the painted item with the specified bounded area.

This method triggers repainting of the painted item within the specified area only. The area is defined by the x, y, width, and height properties of the itema.

See also paint.

Available under certain Qt licenses.
Find out more.