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)));
    view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    OpenGLScene
    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
    item->setPos(10,500);
    scene->addItem(item);
    view.setScene(scene);
    view.show();
    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);
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.