I have a project that will load an HTTP page, parse it and then open other pages based on the data received from the first page.
Since Qt QNetworkAccessManager works asyncronusly, it seems that I should be able to load more than one page at a time while continuing to make HTTP requests, and then the response will be taken care of in the order in which the responses are returned and will be processed in an even cycle.
I have a few problems figuring out how to do this:
At first I read somewhere in stackoverflow that you should use only one QNetworkAccess manager. I do not know if this is true.
The problem is that I am connecting to a ready-made slot in one QNetworkAccess manager. If I make several requests at the same time, I donβt know which request the ready signal answers. I donβt know if there is a way to check the QNetworkReply object, which is transmitted from the signal, to find out which answer it answers? Or should I use a different QNetworkAccessManager for each request?
Here is an example of how I am now clinging to things. But I know that this will not work when I make several requests during:
from PyQt4 import QtCore,QtGui,QtNetwork class Example(QtCore.QObject): def __init__(self): super().__init__() self.QNetworkAccessManager_1 = QtNetwork.QNetworkAccessManager() self.QNetworkCookieJar_1 = QtNetwork.QNetworkCookieJar() self.QNetworkAccessManager_1.setCookieJar(self.QNetworkCookieJar_1) self.app = QtGui.QApplication([]) def start_request(self): QUrl_1 = QtCore.QUrl('https://erikbandersen.com/') QNetworkRequest_1 = QtNetwork.QNetworkRequest(QUrl_1)
source share