Looking at the documentation here [1] I figured out tht I could query the
error status of a QNetworkReply object by calling its meber function
"error()".
It turned out that it is actually not possible (with PySide); when executing
the attached python code, I got this error:
Error calling slot "testNetwork"
Traceback (most recent call last):
File "./provanet.py", line 28, in testNetwork
neterr = netrepl.error()
TypeError: 'Signal' object is not callable
It seems to me that QNetworkReply.error() meber function is missing and it's
trying to call the signal (which happens to have the same name) instead.
[1]
http://www.pyside.org/docs/pyside/PySide/QtNetwork/QNetworkReply.html#PySide.QtNetwork.QNetworkReply.error
--
Luca Donaggio
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtMaemo5 import *
from PySide.QtNetwork import *
import sys
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.cw = QWidget(self)
self.vbox = QVBoxLayout(self.cw)
# Add some Maemo5 stuff to it
self.button = QPushButton(self)
self.button.setText(QString('Network test'))
self.label = QLabel()
self.vbox.addWidget(self.button)
self.vbox.addWidget(self.label)
self.setCentralWidget(self.cw)
# Connect button to signal
self.connect(self.button, SIGNAL("clicked()"), self.testNetwork)
def testNetwork(self):
manager = QNetworkAccessManager(self)
netrepl = manager.get(QNetworkRequest(QUrl("http://www.google.com")))
while not netrepl.isFinished():
self.label.setText('Network test in progress... ')
QCoreApplication.processEvents()
neterr = netrepl.error()
self.label.setText('Network test result: ' + neterr)
if __name__ == '__main__':
app = QApplication(sys.argv)
sw = MainWindow()
sw.show()
sys.exit(app.exec_())
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside