PyQt icons missing?


I am new to PyQt and I am learning to make GUIs based on online tutorials I found. One of the examples in the tutorials uses an icon, here is the code from the tutorial:

import sys
from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication
from PyQt5.QtGui import QIcon

class Example(QMainWindow):

    def __init__(self):


    def initUI(self):               

        exitAct = QAction(QIcon('exit24.png'), 'Exit', self)

        self.toolbar = self.addToolBar('Exit')

        self.setGeometry(300, 300, 300, 200)

if __name__ == '__main__':

    app = QApplication(sys.argv)
    ex = Example()

The output according to the tutorial should be

enter image description here
But for me it’s this

enter image description here
As I said, I just started with PyQt and I just installed PyQt through pip

pip install PyQt5

I’m using Python3.6 and PyQt5. Any help is greatly appreciated!

Asked By: vdvaxel



Yes, PyQt5 does come with a list of default icons. You can find them here:
List of PyQt Icons

However, it seems the “exit” icon from the tutorial you refrenced used a local icon downloaded on their computer. You need to download the same icon and name it ‘exit24.png’ next to your python file.

Answered By: Suraj Kothari

Yes, you can simply follow these steps from here:
How to set icon to a window in PyQt5 ?

Also you can use the QT Designer which can be downloaded from here:
Qt Designer Download and add the icon basically from there.

Alternatively, you can use the Pyinstaller to add icon on the GUI executable. You can follow the steps: Pyinstaller Usage

Answered By: mcagriaksoy
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.