You have to subclass QNetworkAccessManager and reimplement createRequest().
I'm already doing this but in a different way.
QNetworkReply *
NetworkAccessManager
::createRequest( Operation op,
const QNetworkRequest
& req,
QIODevice * outgoingData
){
QNetworkReply * reply = QNetworkAccessManager::createRequest(op, req, outgoingData);
if (checkIfAsync(req.url().toString()))
{
QObject::connect(reply,
SIGNAL(finished
()),
this,
SLOT(asyncFinishedHandler
()));
}
return reply;
}
QNetworkReply *
NetworkAccessManager::createRequest( Operation op, const QNetworkRequest & req, QIODevice * outgoingData)
{
QNetworkReply * reply = QNetworkAccessManager::createRequest(op, req, outgoingData);
if (checkIfAsync(req.url().toString()))
{
QObject::connect(reply, SIGNAL(finished()), this, SLOT(asyncFinishedHandler()));
}
return reply;
}
To copy to clipboard, switch view to plain text mode
I would like to rewrite it in such a way I wouldn't have to connect individual replies with my slot anymore. I would like to handle the difference in reply's type in one place, in handler of this signal:
void QNetworkAccessManager::finished ( QNetworkReply * reply ) [signal]
void QNetworkAccessManager::finished ( QNetworkReply * reply ) [signal]
To copy to clipboard, switch view to plain text mode
Then you can return whatever you want.
Any customer can have a car painted any colour that he wants so long as it is black. -- Henry Ford
C++ supports only* covariant return types in overridden virtual functions. (* - my addition.)
Shortly speaking you can't return whatever you want
But the question was how to subclass QNetworkReply?
Having
class MyNetworkReply : public QNetworkReply
{
bool myFlag;
};
class MyNetworkReply : public QNetworkReply
{
bool myFlag;
};
To copy to clipboard, switch view to plain text mode
how to reuse
QNetworkReply
* QNetworkAccessManager
::createRequest ( Operation op,
const QNetworkRequest
& req,
QIODevice * outgoingData
= 0 ) [virtual protected]
QNetworkReply * QNetworkAccessManager::createRequest ( Operation op, const QNetworkRequest & req, QIODevice * outgoingData = 0 ) [virtual protected]
To copy to clipboard, switch view to plain text mode
to set QNetworkReply part of MyNetworkReply object?
Bookmarks