[英]How to determine the visible area of QQuickPaintedItem?
QML中是否有等效的Win32 GetUpdateRect函數 ? 例如,如果從QQuickPaintedItem派生的控件在Flickable內,有一種方法可以獲得應該重繪的最小矩形
QQuickPaintedItem::paint(QPainter *painter)
?
當您調用QQuickPaintedItem::update()
,給定的QRect
參數將被設置為QQuickPaintedItem::paint
QPainter
剪輯邊界rect 。
因此,如果要重新繪制項目的特定區域,只需使用要重繪的矩形調用QQuickPaintedItem::update()
。
item->update(QRect(10, 20, 30, 20));
void CharacterItem::paint(QPainter *painter)
{
qDebug() << painter->clipBoundingRect() << painter->clipPath();
}
它會顯示:
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.