QQuickItem类的boundingRect从哪里获取其值?

时间:2016-04-20 09:57:18

标签: qt qtquick2 qquickitem

http://doc.qt.io/qt-5/qquickitem.html

QSGNode *MyItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *)
{
    QSGSimpleRectNode *n = static_cast<QSGSimpleRectNode *>(node);
    if (!n) {
        n = new QSGSimpleRectNode();
        n->setColor(Qt::red);
    }
    n->setRect(boundingRect());
    return n;
}

我检查了“列出所有成员”列表,但在那里找不到:http://doc.qt.io/qt-5/qquickitem-members.html

1 个答案:

答案 0 :(得分:1)

它来自项目的宽度和高度:

QRectF QQuickItem::boundingRect() const
{
    Q_D(const QQuickItem);
    return QRectF(0, 0, d->width, d->height);
}