Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to update current QQuickItem's transform with c++?



  • QQucikItem has a updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData * data) interface,
    Can i use the data->transformNode as current item's transform?
    i'am trying something like:

    QSGNode *BaseItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData * data)
    {
        QSGTransformNode *transformNode = data->transformNode;
    
        if ( move )
        {
            qDebug()<< "move...";
            QMatrix4x4 rotationMatrix;
            rotationMatrix.translate(width()/2, height()/2);
            rotationMatrix.rotate(20, QVector3D(0,0,1));
            rotationMatrix.translate(-width()/2, -height()/2);
            transformNode->setMatrix( rotationMatrix * transformNode->matrix() );
            transformNode->markDirty( QSGNode::DirtyMatrix );
        }
    
        return oldNode;
    }
    

    the item does not get rotated.



  • ok, when i periodically call this->update() , it works


Log in to reply