Reputation: 1416
I have the following very simple class:
#ifndef SLAVECALIBRATIONGRAB
#define SLAVECALIBRATIONGRAB
#include <stdint.h>
class SlaveCalibrationGrab{
public:
SlaveCalibrationGrab() : data(0) {}
SlaveCalibrationGrab(int data_) : data(data_){}
SlaveCalibrationGrab(const SlaveCalibrationGrab& other){
data = other.data;
}
~SlaveCalibrationGrab(){}
private:
int data;
};
Q_DECLARE_METATYPE(SlaveCalibrationGrab);
#endif
This throws the following error:
C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Anybody know what I am doing wrong?
Upvotes: 2
Views: 1879
Reputation: 283
I assume you are talking about Qt's Q_DECALRE_METATYPE
? That is defined in #include <QMetaType>
. Add that include. Here is a link to the documentation: Qt5.5 QMetaType
Quote from the doc:
Ideally, this macro should be placed below the declaration of the class or struct. If that is not possible, it can be put in a private header file which has to be included every time that type is used in a QVariant.
Adding a Q_DECLARE_METATYPE() makes the type known to all template based functions, including QVariant. Note that if you intend to use the type in queued signal and slot connections or in QObject's property system, you also have to call qRegisterMetaType() since the names are resolved at runtime.
Upvotes: 6