Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QtQUick and Raspberry, how to use the main loop
Qt 6.12 LTS is out! See what's new in the release blog

QtQUick and Raspberry, how to use the main loop

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DarkPatate
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      D 1 Reply Last reply
      2
      • mrjjM mrjj

        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

        D Offline
        D Offline
        DarkPatate
        wrote on last edited by
        #3

        @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 use Q_INVOKABLE?

        Thanks in advance.

        mrjjM 1 Reply Last reply
        0
        • D DarkPatate

          @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 use Q_INVOKABLE?

          Thanks in advance.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @DarkPatate said in QtQUick and Raspberry, how to use the main loop:

          Q_INVOKABLE

          Hi
          Yes that can work.
          https://stackoverflow.com/questions/9341005/connecting-c-with-qml-using-q-invokable?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt
          • Unsolved