Right Way of Updating a QML File from C++
-
I just started learning QML. I have the following files in my application:
- main.cpp
- connection_handler.h/cpp
- main.qml
- MainForm.ui.qml
I am launching the qml file from main.cpp using
@ QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));QObject *root = engine.rootObjects().first();@
The connection_handler class just initiates a TCP connection and updates the UI regarding the status. Currently, I am using signals and slots for the UI update. I am connecting the signals and slots from main.cpp.
For updating the UI, am I doing this the right way or would you recommend better ways to accomplish this?
-
bq. Currently, I am using signals and slots for the UI update. I am connecting the signals and slots from main.cpp.
Yes that is also a right way. For other approaches you can check "this":http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html doc.
-
[quote author="p3c0" date="1421902957"]
Yes that is also a right way. For other approaches you can check "this":http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html doc.[/quote]Thanks very much.