我有这样的代码:
class A : public QObject
{
Q_OBJECT
public:
explicit A(QObject *parent = 0) : QObject(parent)
{
connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool)));
}
void sendRequest()
{
// ...
http.request(...);
}
public slots:
void httpDone(bool)
{
qDebug() << "recieved!";
}
protected:
QHttp http;
};
class B : public A
{
//...
void getSomething()
{
sendRequest();
}
};
class C : public A
{
//...
void getSomething()
{
sendRequest();
}
};
// and now do some stuff
B b;
C c;
b.getSomething();
c.getSomething();
只有一个“收到了!”来自b的控制台中的消息。为什么呢?
答案 0 :(得分:0)
您可以检查所有派生类中是否有Q_OBJECT宏。