How to specify absolute paths for QIcon

How to specify absolute path like
self.setWindowIcon(QIcon(“D://abc/”+‘resource / logo.ico’))

Hey @qinhong_lai if you’re building paths in Python it’s a good idea to use òs.path.join to rather than joining strings together, e.g.

self.setWindowIcon(QIcon(
    os.path.join('D:\\', 'abc', 'resource', 'logo.ico')

That said, you really don’t want to use absolute paths to point to your icons. Doing this will mean the icon must in the same location on every computer you distribute the application to.

If you’re having trouble including the file with your application, take a look at this tutorial Packaging PyQt5 applications for Windows, with PyInstaller – it explains a number of different ways to do it.