C++ communication with QML in QT
-
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)
-
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)
@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_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
-
S serkan_tr has marked this topic as solved on