Slot executions problems in a new thread
-
Do you have a "Q_OBJECT":http://developer.qt.nokia.com/doc/qt-4.8/qobject.html#Q_OBJECT macro also in GestoreComunicazioneEmh class definition?
-
Are you missing the Q_OBJECT macro?
-
Now I have:
@
class GestoreComunicazioneEmh : public GestoreComunicazioneBase
{
Q_OBJECT
public:
GestoreComunicazioneEmh()
...
...
@But with Q_OBJECT the compilation fails:
@
Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Debug/../satellite/gestorecomunicazioneemh.cpp:10: undefined reference to `vtable for GestoreComunicazioneEmh'
@I think it's should be a very stupid problem but I can't find it...
-
Re-run qmake. If your class is defined within a <code>.cpp</code> file make sure you <code>#include "filename.moc"</code>.
-
So is it solved? Because it seems that you haven't added the QObject as base class of GestoreComunicazioneEmh:
@
class GestoreComunicazioneEmh : public QObject, public GestoreComunicazioneBase
{
Q_OBJECT
public:
GestoreComunicazioneEmh(QObject* parent=NULL) : QObject(parent) {}
};
@ -
[quote author="favoritas37" date="1327329544"]So is it solved? Because it seems that you haven't added the QObject as base class of GestoreComunicazioneEmh:
@
class GestoreComunicazioneEmh : public QObject, public GestoreComunicazioneBase
{
Q_OBJECT
public:
GestoreComunicazioneEmh(QObject* parent=NULL) : QObject(parent) {}
};
@[/quote]This is WRONG! GestoreComunicazioneBase already inherits from QObject, so GestoreComunicazioneEmh is also a QObject subclass, albeit not a direct child class. Adding QObject to the inheritance list makes GestoreComunicazioneEmh in fact inherit from QObject twice, which is a bad, bad, bad idea.
-
Sorry Volker, i mentioned it because i haven't noticed that the base class already inherits from QObject. I wouldn't suggest to inherit twice from QObject.
-
[quote author="favoritas37" date="1327332502"]Sorry Volker, i mentioned it because i haven't noticed that the base class already inherits from QObject. I wouldn't suggest to inherit twice from QObject. [/quote]
No problem, everyone overlooks something now and then :) I just wanted to make sure that another potential trouble maker does sneak in :)