PDA

View Full Version : Signal do not work in derived class



nickla
19th March 2011, 22:25
I have such code:


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();


And there is only one "recieved!" message in console from b. Why?

Added after 14 minutes:

From qDebug() << connect(..) output I see that SIGNAL connects to SLOT (return value is true).

Added after 17 minutes:

Sorry.., it`s my fault. And that is why I have to go to sleep right now.