I'm writing classes for widgets on a ui. While planning what I would do, I realized majority of the of the classes would look very similar. What I decided to do was to use a macro that takes a few parameters to define the similar parts of the class bodies. After cleaning a few code errors, I compiled and got a bunch of linker errors. I cleaned and rebuilt a few times with the same result
All of the errors say: error: undefined reference to vtable for 'every class using the macro'. I have an idea the errors are related to using Qt signals and slots with in the macro, but I dont know for sure or how I'd solve the the problem if that is what's causing it.
This is one of the macros that cause some of the errors:
#define GENERAL_GUI_ITEM_CLASSBODY(SIG,EMIT_TYPE) \
\
Q_OBJECT \
\
EMIT_TYPE val; \
public: \
inline void connectSIG() \
{ \
connect(this, SIGNAL(SIG), SLOT(emitRequest())); \
} \
\
inline void setVal (EMIT_TYPE v) { val = v; } \
\
signals: \
void requested(EMIT_TYPE); \
private slots: \
inline void emitRequest() { emit requested (val); } \
public:
The other macros I'm using have a few more functions all inline and cause the same errors.