QT QML Application slower compared to Widget Application in Python

Hello everyone,

I am trying to create a graphical user interface which will run on a QT container on Torizon.

I have tried two different methods to create the graphical user interface. For method 1 I generated the GUI using a QML file and for method 2 I used the QWidgets. I found out that generating a GUI with QWidgets is much faster.

However, I read on different website that a GUI with QtQuick should be faster compared to a GUI with QWidgets. Am I doing something wrong with loading the QML file or is a GUI with QWidgets faster on the Toradex modules compared to a GUI with a QML file?

For both applications, I have used python 3.10.9 together with PySide2. I am running the application on Torizon using a Toradex module with the IMX8 chip.

The code which I use to load the QML file in Python is written down below. This code is the same code as the sample code which Torizon provides when you select in Visual Studio Code that you want to create a QT Python Application with QML.

import sys
import os
import PySide2
from PySide2.QtWidgets import QApplication
from PySide2.QtCore import QUrl, QObject
from PySide2.QtQuick import QQuickView

if __name__ == "__main__":
    print("Hello world!")

    app = QApplication(sys.argv)

    view = QQuickView()

    qml = QUrl("mainwindow.qml")

    view.setSource(qml)
    view.show()

    sys.exit(app.exec_())

Thank you!

QWidgets is written in C++ and could be faster than QML that uses JavaScript. The performance of QML also depends on how complex the QML file is and how well it’s optimized.
You can use performance tools such as “Qt Quick Profiler” to profile your application and identify the bottlenecks.

1 Like

Hello @xAnouk,

I hope that the reply from @alex.tx answers your question. Have you already tried profiling the performance of your application using Qt Quick Profiler?