python - Why must QApplication.processEvents() be called until QNetworkRequest is finished when using QWebView? -


Normally, when I make a network request through QT 4.8, then I QApplication.processEvents) / Code> ()

However, when I issue a network request from Javascript in a QWebView , it will not work until the request is terminated until the call is completed It is not done, as seen below.

Clearing:
process events () except for calls calls Quattrocore, QTGui, QTNetwork, QTWBKit client, MANDONDO (Qtgui QumenWindows): def __init __ (self): Super pi QT4 import

  has expired. (MainWindow, self) .__ init __ () QtNetwork.QNetworkProxyFactory.setUseSystemConfiguration (True) self.view = QtWebKit.QWebView (self) self.setCentralWidget (self.view) self.view.setPage (QtWebKit.QWebPage (self.view )) Self.view.page () Main frame (). JavascriptWindowObjectCleared.connect (self.refreshJS) self.view.setHtml ('' '' & lt; html & gt; & lt; body & gt; Loading ... & lt; script & gt; & lt ;! - APP Request (); // - & gt; & lt; / script & gt; & lt; / body & gt; & lt; / html & gt; '' ') @ QtCore.pyqtSlot () Def request (self): Request = QtNetwork.QNetworkRequest (QtCore.QUrl ('http: //localhost/test.php')) Manager = QtNetwork.QNetworkAccessManager () Manager.finished.connect (self.managerFinished) Reply = manager.post (Request, B ' A = A ') Answer End. Connect (Own.) ############################################# ################## Fix me: If this is unavailable, then the request * has never been sent * ### ########### ############################################### While Not Answering Given. Success (): QtGui.QApplication.processEvents () #################################### ################## Print ('Finished): Print (' Finished ') def manager Finished (self): Print (' managerfinished ') Def Refresh JS (Self) ): Print ('Refresh JS') self.view.p. (). ('APP', itself) if __name__ == '__main__': import OS, sys app = QtGui.QApplication (sys.argv) MainWindow (). Show () sys.exit (app) .exec_ ())  

QNetworkAccessManager and one There is a big difference between your use of the link Note that your version is synchronous: By waiting for the answer, you block the event loop in the 'request' slot, thus QNetworkAccessManager can not work as long as That you do not push events with your hands. The examples raised on the other side are asynchronous: this creates a request, 'finished' sign Adds taps and gives the event loop to function. In this way the event loop is not blocked and the network manager works well. I understand that in your situation the 'request' slot should be synchronous, so process avents should be here.

EDIT

If you have requested asynchronous, then you need to make sure that QNetworkAccessManager Object request is continuous outside the method. Start it in __init __ (self) and post it in the request. Perhaps QNetworkReply` should also be continuous, you have to check it out.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -