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