Notification texts go here Contact Us Buy Now!

Icons in PyQt application not showing up

If you're encountering issues with icons not displaying in your PyQt application, here's a solution that has helped others resolve this problem:

  1. Add "icons" to the Prefix: In your resource file (.qrc), add "icons" to the prefix of the resources. For instance, if you have an icon named "icon.png," you would change the prefix to "icons.icon.png."
  2. Convert .qrc File to Python Code: Use the pyside-rcc tool to convert the .qrc file into a Python code file, such as icons_rc.py. Refer to the PyQt documentation page for guidance on using pyside-rcc.
  3. Import the Generated Python Code: In your main Python script, import the generated Python code (e.g., import icons_rc) to access the icons.

After implementing these steps, the icons should appear correctly in your PyQt application.


Additionally, for those using PyQt5 or PyQt6 on Python, here's a crucial tip:

When compiling or designing your application, use the MEI PASS to specify the location of the icons. This ensures that the executable can find the icons in the temporary folder rather than the executable's location.

executable_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(sys.argv[0])))

By incorporating this code, you can ensure that the icons will be correctly displayed in your PyQt application.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.