preface

PyQt5 = Pycharm = PyQt5 = PyQt5 You must use the previous project's (Preject Interpreter) first. The error is reported as followsCopy the code

All right, question out of the way, back to the point. Back to today's topic - setting the icon icon for your applicationCopy the code

The libraries used are as follows

 import sys
 from PyQt5.QtWidgets import *
 from PyQt5.QtCore import *
 from PyQt5.QtGui import QIcon
Copy the code

Two complete small Demo

import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import * from PyQt5.QtGui import QIcon class MJBMainWindow(QWidget): def __init__(self): super(MJBMainWindow, self).__init__() self.initUI() def initUI(self): Self. SetWindowTitle (" application Settings icon ") if __name__ = = "__main__ ': app = QApplication(sys.argv) icon = QIcon('./AppIcon/[email protected]') app.setWindowIcon(icon) m = MJBMainWindow() m.show() sys.exit(app.exec())Copy the code

The effect of operation

subsequent

Because I just learn QT, if there is something wrong, please spray lightlyCopy the code