QIcon
Web からデータを取得することはできません。自分でダウンロードして に渡す必要がありますQIcon
。このようなもの:
import sys
from PyQt4 import QtGui, QtCore, QtNetwork
class Main(QtGui.QMainWindow):
def __init__(self, parent=None):
super(Main, self).__init__(parent)
def loadIconFromUrl(self, url):
manager = QtNetwork.QNetworkAccessManager(self)
manager.finished.connect(self._setIconFromReply)
manager.get(QtNetwork.QNetworkRequest(QtCore.QUrl(url)))
def _setIconFromReply(self, reply):
p = QtGui.QPixmap()
p.loadFromData(reply.readAll(), format="ico")
self.setWindowIcon(QtGui.QIcon(p))
app = QtGui.QApplication(sys.argv)
main = Main()
main.loadIconFromUrl("http://en.wikipedia.org/favicon.ico")
main.show()
sys.exit(app.exec_())