0
类
工作,我有这样的代码:“收到”信号不派生
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的控制台中的消息。为什么?
什么给'B'和'C'的构造函数看起来像? – Mat 2011-03-19 22:01:00
你需要发布一个完整的例子。像这样可以确定你是否有适当的事件循环。 – 2011-03-20 02:04:39
信号在派生类中工作正常 - 检查connect()的返回码它告诉你如果你犯了一个错误 – 2011-03-20 04:26:29