Qt eror: Underfined Reference To
-
I am building a QT Creator program that performs two tasks: Task 1: Receive yaw pitch roll signals from esp32 via wifi with tcp socket protocol and display them using label and charts.
Task 2: On the interface, there will be 4 LineEdits to enter coordinates and tilt angle, then send those 4 LineEdits via wifi to esp32.
In the source code, it will be divided into 2 header files and 2 cpp files. mainwindow.h and mainwindow.cpp will be responsible for designing the interface and receiving yaw pitch roll then display them; Worker.h and Worker.cpp will be responsible for performing the second task. i am getting "undefined reference to Mainwindow::sendDataBack " error but i have written the declaration in worker.h and definition in worker.cpp.i have tried changing the order of included header files but no luck Please help me! i only have 9 days left i also checked every thing to see if i write my function correct but no use.
-
Hi and welcome to devnet,
It should rather be:
- have one controller class that is responsible for communicating with the device
- have one GUI class that will make use of the controller
The controller class shall not know anything about the GUI, it's not its role to update the GUI. What it needs to do is emit signals when something new arrives. The GUI shall connect to these signals and do whatever they want with the values received. Give proper API to the controller that the GUI can call to send data to the device.
Keep things clearly and cleanly separated.
-
S SGaist moved this topic from Qt in Education on
-
Hi and welcome to devnet,
It should rather be:
- have one controller class that is responsible for communicating with the device
- have one GUI class that will make use of the controller
The controller class shall not know anything about the GUI, it's not its role to update the GUI. What it needs to do is emit signals when something new arrives. The GUI shall connect to these signals and do whatever they want with the values received. Give proper API to the controller that the GUI can call to send data to the device.
Keep things clearly and cleanly separated.
-
Unless it's trade secret, you can post it here.
-
I am building a QT Creator program that performs two tasks: Task 1: Receive yaw pitch roll signals from esp32 via wifi with tcp socket protocol and display them using label and charts.
Task 2: On the interface, there will be 4 LineEdits to enter coordinates and tilt angle, then send those 4 LineEdits via wifi to esp32.
In the source code, it will be divided into 2 header files and 2 cpp files. mainwindow.h and mainwindow.cpp will be responsible for designing the interface and receiving yaw pitch roll then display them; Worker.h and Worker.cpp will be responsible for performing the second task. i am getting "undefined reference to Mainwindow::sendDataBack " error but i have written the declaration in worker.h and definition in worker.cpp.i have tried changing the order of included header files but no luck Please help me! i only have 9 days left i also checked every thing to see if i write my function correct but no use.
@MinhVN said in Qt eror: Underfined Reference To:
i am getting "undefined reference to Mainwindow::sendDataBack " error but i have written the declaration in worker.h and definition in worker.cpp.
The declaration and definition for
Mainwindow::sendDataBack()
would normally be expected in the files mainwindow.h/mainwindow.cpp (or something like that). If the Worker class needs to accessMainWindow::sendDataBack()
then you should only need an#include "mainwindow.h"
in the relevant Widget source or header.The error message is a linker error. It could be because you have incompatible declarations in the two places.
-
@MinhVN said in Qt eror: Underfined Reference To:
i am getting "undefined reference to Mainwindow::sendDataBack " error but i have written the declaration in worker.h and definition in worker.cpp.
The declaration and definition for
Mainwindow::sendDataBack()
would normally be expected in the files mainwindow.h/mainwindow.cpp (or something like that). If the Worker class needs to accessMainWindow::sendDataBack()
then you should only need an#include "mainwindow.h"
in the relevant Widget source or header.The error message is a linker error. It could be because you have incompatible declarations in the two places.
-
S SGaist has marked this topic as solved on