Unsolved QtQUick and Raspberry, how to use the main loop
-
Hello,
I'm used to code with classic Qt, but I just started with QML and Qt Quick.My aim is to use my app on a Rpi with a LCD screen. But I don't see how to integrate the RPi part in the program. I want to add some actions in the main loop of the application (getting some information from I2C).
Here is my main.cpp (without includes)
int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); StrategiesModel::declareQML(); Communication::declareQML(); QQuickStyle::setStyle("Material"); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }
I created the Communication class to that purpose, but I'm not sure if it's the right way.
With classic Qt, I would use the Windows Object and add some signals and slots. But how can I achieve that with QML (keeping interactions beetween QML interface and C++ program)?
Thanks in advance.
-
Hi
did you read this ?
http://doc.qt.io/qt-5/qtqml-cppintegration-topic.html
QML also have signals and slots
http://doc.qt.io/qt-5/qtqml-syntax-signals.html -
@mrjj I found many docs but not your links, thanks!
For the first one, I did the same, so I now it's the right way now.For the second one, it'll be really helpfull, thanks again!
One more question: I now how to access to property signal of my class in QML with
Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged)
. But how can I access to signals/slots not linked to a property? I have to useQ_INVOKABLE
?Thanks in advance.
-