Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. C++ communication with QML in QT
Qt 6.11 is out! See what's new in the release blog

C++ communication with QML in QT

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 344 Views 2 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.
  • serkan_trS Offline
    serkan_trS Offline
    serkan_tr
    wrote on last edited by serkan_tr
    #1

    I want to create a bridge between QML and C++. I'm working on a project, I read the data from the serial port and print it on the screen. I can't share because there are too many files and the codes are too long.

    -> I simply added 4 files to the system, the first file reads the serial port and generates a signal every time there is data, and I connected this signal to the 2nd file with the help of slot.

    ->2nd file transfers incoming data to 3rd file with the help of signal slot.

    ->The 3rd file is a C++ file, but to create this class on the QML side, I give it as a library to the QML side with qmlRegistertype

    ->In the 4th file, the QML file is the part where I wrote the interface part.

    When I connect the C++ side using signal slot and change the 3rd file, it changes on the QML side, so it became the project I wanted.

    but I think I've created too many unnecessary files. Can I directly communicate with the 1st file with the object in the QML side (Note: without creating a new object)

    JKSHJ 1 Reply Last reply
    0
    • serkan_trS serkan_tr

      I want to create a bridge between QML and C++. I'm working on a project, I read the data from the serial port and print it on the screen. I can't share because there are too many files and the codes are too long.

      -> I simply added 4 files to the system, the first file reads the serial port and generates a signal every time there is data, and I connected this signal to the 2nd file with the help of slot.

      ->2nd file transfers incoming data to 3rd file with the help of signal slot.

      ->The 3rd file is a C++ file, but to create this class on the QML side, I give it as a library to the QML side with qmlRegistertype

      ->In the 4th file, the QML file is the part where I wrote the interface part.

      When I connect the C++ side using signal slot and change the 3rd file, it changes on the QML side, so it became the project I wanted.

      but I think I've created too many unnecessary files. Can I directly communicate with the 1st file with the object in the QML side (Note: without creating a new object)

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @serkan_tr said in C++ communication with QML in QT:

      Can I directly communicate with the 1st file with the object in the QML side (NOT without creating a new object)

      Yes: https://doc.qt.io/qt-6/qtqml-cppintegration-overview.html

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      serkan_trS 1 Reply Last reply
      4
      • JKSHJ JKSH

        @serkan_tr said in C++ communication with QML in QT:

        Can I directly communicate with the 1st file with the object in the QML side (NOT without creating a new object)

        Yes: https://doc.qt.io/qt-6/qtqml-cppintegration-overview.html

        serkan_trS Offline
        serkan_trS Offline
        serkan_tr
        wrote on last edited by
        #3

        @JKSH Thank you

        1 Reply Last reply
        0
        • serkan_trS serkan_tr has marked this topic as solved on

        • Login

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