I am trying to use the QT QNetworkAccessManager class to manage some downloads in a multithreaded C ++ / QT application.
In a work thread (editing: a thread separately for other reasons than loading), I would like to access an external server and be ready to get the results with the code:
... m_nam = new QNetworkAccessManager(this); QNetworkReply *reply = m_nam->get(request); connect(m_nam, SIGNAL(finished(QNetworkReply *)), this, SIGNAL(finished(QNetworkReply *))); ...
But I can decide, before the download is complete, that I am not interested in the result.
So, I would like to set up a way to disconnect a connection from another thread by emitting a do_abort () signal.
What prompts:
connect(this, SIGNAL(do_abort()), reply, SLOT(abort()));
But I do not think this will work, because the interrupt is not a QNetworkReply slot.
So, how can I install a mechanism where I can stop this download from another thread? I could subclass QNetworkReply and give this class an appropriate slot. But I would also like to understand the situation.
source share