1、前提存在一个.ico的图标文件

2、如下代码添加图标

import sys
from PyQt5.QtWidgets import QApplication,QMainWindow
from calendar import Ui_MainWindow
from PyQt5.QtGui import QIcon
class wuyue(QMainWindow,Ui_MainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setupUi(self)


if __name__=='__main__':
    app=QApplication(sys.argv)
    asin = wuyue()
    asin.setWindowTitle('实时检测系统')
    icon = QIcon('./resource/2.ico')
    asin.setWindowIcon(icon)
    asin.show()
    sys.exit(app.exec_())

演示:

QT设置程序图标

 

 QT设置程序图标

 

相关文章:

  • 2022-12-23
  • 2021-10-10
  • 2021-08-16
  • 2021-07-26
  • 2021-09-26
  • 2021-12-26
  • 2021-12-20
猜你喜欢
  • 2021-04-03
  • 2021-10-15
  • 2021-08-28
  • 2021-05-23
  • 2021-07-14
  • 2022-12-23
  • 2021-09-24
相关资源
相似解决方案