My question is inside the run function below
{
Q_OBJECT
private:
QNetworkReply *m_reply;
public slots:
void gotNetworkHeader()
{
// do something
}
public:
TestObject
(QUrl url
) : m_url
(url
) {
}
void run()
{
QNetworkAccessManager nam;
m_reply = nam.head(QNetworkRequest(m_url));
connect(m_reply, SIGNAL(finished()), this, SLOT(gotNetworkHeader()));
//
// what do I do here to stop the thread from
// exiting until gotNetworkHeader has finished
// execution?
//
// I've tried exec(), but this seems to block QNetworkAccessManager
}
};
class TestObject : public QThread
{
Q_OBJECT
private:
QNetworkReply *m_reply;
QUrl m_url;
public slots:
void gotNetworkHeader()
{
// do something
}
public:
TestObject(QUrl url) : m_url(url)
{
}
void run()
{
QNetworkAccessManager nam;
m_reply = nam.head(QNetworkRequest(m_url));
connect(m_reply, SIGNAL(finished()), this, SLOT(gotNetworkHeader()));
//
// what do I do here to stop the thread from
// exiting until gotNetworkHeader has finished
// execution?
//
// I've tried exec(), but this seems to block QNetworkAccessManager
}
};
To copy to clipboard, switch view to plain text mode
Bookmarks