I have such code:
{
Q_OBJECT
public:
{
connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool)));
}
void sendRequest()
{
// ...
http.request(...);
}
public slots:
void httpDone(bool)
{
qDebug() << "recieved!";
}
protected:
};
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();
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();
To copy to clipboard, switch view to plain text mode
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.
Bookmarks