Answer the question
In order to leave comments, you need to log in
How to pass an object to a form (Qt)?
I can’t understand what the error is here, the function is written in the form (I’ll show the implementation)
void infoSystem::setDevice(CDevice &d){
device = d;
}
#ifndef INFOSYSTEM_H
#define INFOSYSTEM_H
#include
#include "cdevice.h"
namespace Ui {
class infoSystem;
}
class infoSystem : public QMainWindow
{
Q_OBJECT
public:
explicit infoSystem(QWidget *parent = 0);
~infoSystem();
void setDevice(CDevice &);
private:
Ui::infoSystem *ui;
CDevice *device;
};
#endif // INFOSYSTEM_H
Answer the question
In order to leave comments, you need to log in
The error that the compiler points to, this line should be written like this:
More errors:
1) Your function takes a reference as input, and you pass it a pointer.
2) A member of the device class is also a pointer.
Rewrite to infosystem.h and infosystem.cppvoid infoSystem::setDevice(CDevice *d){
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question