如何从PYQT的网址设置Qicon,你能举个例子吗?
答案 0 :(得分:6)
一个基本的例子是:
from PyQt4.QtGui import *
from PyQt4.QtCore import QUrl
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest
app = QApplication([])
url = "http://www.google.com/favicon.ico"
lbl = QLabel("loading...")
nam = QNetworkAccessManager()
def finishRequest(reply):
img = QImage()
img.loadFromData(reply.readAll())
lbl.setPixmap(QPixmap(img))
nam.finished.connect(finishRequest)
nam.get(QNetworkRequest(QUrl(url)))
lbl.show()
app.exec_()