繁体   English   中英

如何确定QQuickPaintedItem的可见区域?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM