I am not doing much of different that what is described in http://doc.qt.io/qt-5/qtquick-sceneg...l-example.html . Lets compare the sync() there and mine:

Qt Code:
  1. void Squircle::sync()
  2. {
  3. if (!m_renderer) {
  4. m_renderer = new SquircleRenderer();
  5. connect(window(), SIGNAL(beforeRendering()), m_renderer, SLOT(paint()), Qt::DirectConnection);
  6. }
  7. m_renderer->setViewportSize(window()->size() * window()->devicePixelRatio());
  8. m_renderer->setT(m_t);
  9. }
To copy to clipboard, switch view to plain text mode 

Whereas I am doing the following:

Qt Code:
  1. void TriangleSceneItem::sync()
  2. {
  3. if(mScene)
  4. {
  5. connect(mTimer,SIGNAL(timeout()),this,SLOT(updateTime()),Qt::DirectConnection);
  6.  
  7. mScene->setViewportSize(window()->width() * window()->devicePixelRatio(),
  8. window()->height() * window()->devicePixelRatio());
  9. }
  10. }
To copy to clipboard, switch view to plain text mode 

I am creating the timer for the animation and then setting the viewport size that is lated used during rendering. The renderer intialization is done inside the constructor.