QObject::connect returns false
-
@SPlatten said in QObject::connect returns false:
please see the edited post which includes the derived class, sorry.
In this header signal signature is
void updateTime(int)
and notvoid updateTime(long)
@KroMignon , because I changed it from long to int after earlier posts.
-
@SPlatten said in QObject::connect returns false:
@J-Hilk , why? The class it inherits already has that.
That's not how it works. Which is why I said to try putting
Q_OBJECT
in.Can you please do that and then we will discuss why if it makes any difference?
-
@SPlatten said in QObject::connect returns false:
@J-Hilk , why? The class it inherits already has that.
That's not how it works. Which is why I said to try putting
Q_OBJECT
in.Can you please do that and then we will discuss why if it makes any difference?
-
@JonB , adding Q_OBJECT to the inherit class results in the compiler error:
undefined erference to `vtable for clsTimeSync`
@SPlatten said in QObject::connect returns false:
results in the compiler error
You need to do a complete rebuild
-
@SPlatten said in QObject::connect returns false:
why? The class it inherits already has that.
Because it is a Qt recommendation (cf. https://doc.qt.io/qt-5/metaobjects.html)
The meta-object system is based on three things:
- The QObject class provides a base class for objects that can take advantage of the meta-object system.
- The Q_OBJECT macro inside the private section of the class declaration is used to enable meta-object features, such as dynamic properties, signals, and slots.
- The Meta-Object Compiler (moc) supplies each QObject subclass with the necessary code to implement meta-object features.
-
@JonB , adding Q_OBJECT to the inherit class results in the compiler error:
undefined erference to `vtable for clsTimeSync`
-
@SPlatten said in QObject::connect returns false:
results in the compiler error
You need to do a complete rebuild
-
@SPlatten said in QObject::connect returns false:
@J-Hilk , why? The class it inherits already has that.
Q_OBJECT
is a macro. You can look at what it does.I know the rule is:
-
Every class which defines signals MUST have
Q_OBJECT
in that class definition. Inheritance from parent is not what it's about. -
Normally I believe slot-only classes do not have to have
Q_OBJECT
. HOWEVER I only work with the new-styleconnect()
syntax, not available in Qt4. It may be that to useSLOT()
you do also needQ_OBJECT
in old style? When in doubt --- and certainly if I were having a problem --- I would putQ_OBJECT
into classes with slots just in case.....
-