The following code compiles, but I feel that it should not:
// main.cpp
#include <QObject>
#include <iostream>
class MyClass : public QObject {
Q_OBJECT;
public:
MyClass();
void do_it();
signals:
void some_signal(const QString& value);
};
MyClass::MyClass()
{
}
#include "main.moc"
void
MyClass::do_it()
{
emit some_signal("hello, world!");
}
void foo()
{
std::cout << "foo called" << std::endl;
}
int
main()
{
MyClass o;
o.connect(&o, &MyClass::some_signal, &foo);
o.do_it();
return 0;
}
Specifically speaking, the signature of the function I'm connecting to the MyClass::some_signal() signal does not match the signature of the MyClass::some_signal() signal. So it shouldn't even compile. Am I wrong on that, or am I missing to do something here?
Full disclosure: my actual problem is that a slot I'm connecting to a signal I am emitting does not get called. But I feel this problem might be related, and I need to get this issue sorted out anyway.