I am doing an Application on Qt for my Internship and I have a problem.
The purpose of my Application is that I have a card connected by USB to my computer that sends CAN message.
I made an application in C++ on visual studio that received those CAN messages and printed them on the console with the help of a callback.
What I want to do know is to do the same thing but with a GUI application on Qt using the functions that I previously made (I didn't used classes in my visual studio project).
Iadded all my .cpp and .h files from my visual studio project into my QT project
So here is mainwindow.h file where I didn't changed anything. I just added a textLabel on my form.
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QLabel>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
public:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
The main.cpp is very basic.
MainWindow.cpp :
Here is the constructor when I open the communication
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//Function created in Library.
open_com(...)
}
open_com opens the communication and call the callback each time a message is received
Definition of the callback
void callback (message id )
{
Here I want to call my TextLabel from my application
}
And my problem in this application is I don't know how to access my application from a function that is not part of the MainWindow class.
If someone already had this kind of problem and has the solution I would be very gratefull !
Thank you.