本文介紹了如何使用 PyQt5 設置窗口圖標?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
from PyQt5 import QtWidgets, QtGui
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
class Application(QMainWindow):
def __init__(self):
super(Application, self).__init__()
self.setWindowIcon(QtGui.QIcon('icon.png'))
我正在嘗試設置一個窗口圖標(窗口左上角),但正常圖標卻消失了.
I am trying to set a window icon (top left of the window) but the normal icon disappeared instead.
我嘗試了許多圖標分辨率(8x8、16x16、32x32、64x64)和擴展名(.png 和 .ico).
I tried with many icon resolutions (8x8, 16x16, 32x32, 64x64) and extensions (.png and .ico).
我做錯了什么?
推薦答案
asker 建議的命令對我有用:
The command, as suggested by asker, works for me:
self.setWindowIcon(QtGui.QIcon('icon.png'))
我放了 256x256 png,一切正常.我有 Win 7 pro 64 位,Python 3.5.2 32 位.
I put 256x256 png and all was OK. I have Win 7 pro 64 bit, Python 3.5.2 32 bit.
這篇關于如何使用 PyQt5 設置窗口圖標?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!