S
S
Slavka2015-10-10 16:55:35
Qt
Slavka, 2015-10-10 16:55:35

How to pass an object to a form (Qt)?

c549b7efd59d4b61bedc40161db9204e.png
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;

}

PS code is not perfect, just learning
#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

1 answer(s)
A
AtomKrieg, 2015-10-10
@Slavka_online

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.cpp
void infoSystem::setDevice(CDevice *d){

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question