Answer the question
In order to leave comments, you need to log in
PyQt4. How to get result of all requests from QWebView?
Greetings habra-community.
I ran into a problem with getting the results of side queries when using QWebView from PyQt4.
I inherit and customize my QWebView:
class MainWindow(QWebView):<br>
def __init__(self, parent = None):<br>
super(MainWindow,self).__init__(parent)<br>
settings = self.settings()<br>
settings.setAttribute(QWebSettings.JavascriptEnabled,True)<br>
settings.setAttribute(QWebSettings.PluginsEnabled,True)<br>
class CustomManager(QNetworkAccessManager):<br>
def __init__(self, parent = None):<br>
super(CustomManager,self).__init__(parent)<br>
self.connect(self, SIGNAL("finished(QNetworkReply*)"), self.print_response)<br>
<br>
def print_response(self, reply):<br>
print reply.url(), reply.isFinished()<br>
print reply.readAll() #EMPTY!<br>
app = QApplication(sys.argv)<br>
app.setApplicationName("test")<br>
<br>
window = MainWindow()<br>
manager = CustomManager()<br>
window.page().setNetworkAccessManager(manager)<br>
<br>
window.load(QUrl("http://ya.ru/"))<br>
window.show()<br>
sys.exit(app.exec_())<br>
print reply.readAll()
always empty. At the same time, reply.isFinished(), as expected, is True. Answer the question
In order to leave comments, you need to log in
I collected your example from PySide - everything works.
Python 2.6.6, PySide 1.1.0qt474, Win 7 x86
Tried a slightly different option, namely
instead of:
self.connect(self, SIGNAL("finished(QNetworkReply*)"), self.print_response)
self.finished.connect(self.print_response)
PySide.QtCore.QUrl('http://www.yandex.ru/data/mail.js?yaru=y') True
PySide.QtCore.QUrl('http://kiks.yandex.ru/system/fc06.html') True
PySide.QtCore.QUrl('http://kiks.yandex.ru/system/fc06.swf') True
PySide.QtCore.QUrl('http://suggest.yandex.ru/jquery-1-4-2.crossframeajax.html') True
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question