N
N
NitroDesktop2020-05-11 17:46:25
Python
NitroDesktop, 2020-05-11 17:46:25

How to add an icon to an exe in qt5 that would not be in the folder?

When I run it with an icon in the folder, it works, but when I remove the icon from the folder, there are no icons!

app_icon = QtGui.QIcon()
        app_icon.addFile('1.ico', QtCore.QSize(16,16))
        app_icon.addFile('3.ico', QtCore.QSize(24,24))
        app_icon.addFile('4.ico', QtCore.QSize(32,32))
        app_icon.addFile('5.ico', QtCore.QSize(48,48))
        app_icon.addFile('10.ico', QtCore.QSize(118,118))
        Dialog.setWindowIcon(app_icon)

How to embed in exe file?

Compiled like this:
pyinstaller --onefile --icon=1.ico -w outputpyfile.py


In the folder, the program shows an icon, but if you run it, you can see that the icon does not work in qt itself

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andy_U, 2020-05-11
@NitroDesktop

Using the environment variable _MEIPASS will save the poor cat from starvation. I have answered questions like this many times here. Whether you added an icon to the "distribution", I don't know. One, maybe, but obviously not all.
PS Read

A
Alexander Ananiev, 2020-05-11
@SaNNy32

Need to add an icon to the application resources

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question