Nominate our 2022 Qt Champions!

Render Qml efficiently on GraphicsView

  • Hi all,

    My code is below.

    How do I efficiently render qml on graphicsView? my animation qml is appearing very slow when rendered in QDeclarativeEngine. Is there a way to optimise it at the c++ level?

    It was running ok at qml level.

    Thank you

    int main(int argc, char *argv)
    QApplication app(argc, argv);
    GraphicsView view;
    view.setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    scene = new OpenGLScene;
    // provides an environment for instantiating QML components
    QDeclarativeEngine engine;
    // encapsulates a QML component definition
    QDeclarativeComponent component(&engine, QUrl::fromLocalFile("BounceAnimation.qml"));
    // creates the graphics item for QML at the engine's root context
    QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(component.create());
    // set position of item
    view.resize(1024, 2000);

    return app.exec(&#41;;


  • Thanks Lukas for the reply.

    Is there render performance difference comparing the QDeclarativeView with QDeclarativeEngine?

    Also, i did the following but the qml rendering is still not smooth. Any other advices? anyone?

    @ scene->setStickyFocus(true);

Log in to reply