Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to update current QQuickItem's transform with c++?

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

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 592 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • tracymaT Offline
    tracymaT Offline
    tracyma
    wrote on last edited by
    #1

    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.

    tracymaT 1 Reply Last reply
    0
    • tracymaT tracyma

      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.

      tracymaT Offline
      tracymaT Offline
      tracyma
      wrote on last edited by
      #2

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

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved