I'm getting a weird error with my slots and signals code in Qt v4.8.5. Whenever I include my QObject
with slots:
class dnEventHandler : public QObject
{
Q_OBJECT
public slots:
void LaunchProjectCreator();
};
I get some odd errors:
Main.cc:(.text.startup+0x4b): undefined reference to `vtable for dnEventHandler'
Main.cc:(.text.startup+0x19e): undefined reference to `vtable for dnEventHandler'
Main.cc:(.text.startup+0x20d): undefined reference to `vtable for dnEventHandler'
I thought this was pretty strange, since it seemed the error had something to do with headers in the .pro
, but I already had my headers in an include path in the .pro
like so:
INCLUDEPATH += ../../include/
Why am I getting undefined references like this with my headers in my include path?
Turns out you have to manually specify all your headers with slots in the
.pro
:Qt has to use this to generate MOC (Meta Object Code) files.