Reputation: 4305
Is there an equivalent of Win32 GetUpdateRect function in QML? For example, if a control derived from QQuickPaintedItem is inside Flickable is there a way to get the smallest rectangle that should be redrawn in
QQuickPaintedItem::paint(QPainter *painter)
?
Upvotes: 0
Views: 237
Reputation: 6594
When you call QQuickPaintedItem::update()
, the given QRect
parameter will be set as clip bounding rect for your QPainter
in QQuickPaintedItem::paint
.
So, if you want to redraw a specific region of your item, just call QQuickPaintedItem::update()
with the rect you want to repaint.
item->update(QRect(10, 20, 30, 20));
void CharacterItem::paint(QPainter *painter)
{
qDebug() << painter->clipBoundingRect() << painter->clipPath();
}
It will display:
QRectF(10,20 30x20)
QPainterPath: Element count=5
-> MoveTo(x=10, y=20)
-> LineTo(x=40, y=20)
-> LineTo(x=40, y=40)
-> LineTo(x=10, y=40)
-> LineTo(x=10, y=20)
Upvotes: 1