Not too sure how to formulate my question and I hope that this is more clear. I want to have a baseclass that looks something like this:
class Base : public QObject {
Q_OBJECT
void doSomething() { emit test(this); }
virtual void doSomethingElse() = 0;
signals:
void test(Base*);
}
And then in the derived class do this:
class Derived : public Base {
void doSomethingElse() { emit test(this); }
}
If I now listen to the signals of this object and do I listen to test(Derived*) or/and test(Base*)?
The moc generates at compile time a list of the slots and signals based on the way you declared them in the classes that use the Q_OBJECT
macro.
This list is a list of strings, so if you declared:
signals:
void test(Base*);
the item in the list would be the string "test(Base*)"
(you can see that list in the variable qt_meta_YourClass
of the file moc_yourclass.cpp
in the output directory).
The macros SIGNAL
and SLOT
also return strings, connect()
canonize them so they are formatted like the one from the moc generated list, and compares them to those in that list.
When you derive the class, the string hasn't changed, so you still have to use SIGNAL(test(Base*))
.