[Python] Images not displaying in PyQt on Ubuntu but work on Windows

Discussão em 'Python' iniciado por Stack, Julho 31, 2025.

  1. Stack

    Stack Membro Participativo

    I am using the rcc tool to convert the resources from qrc to py file. On Windows, this works well and all my images display perfectly.

    I copied the app to Ubuntu 24 and the app works as expected, but none of the images display. I assumed this was because the resource py file was made on Windows, so I regenerated it on Ubuntu with rcc matching the version of Qt/PyQt. Still nothing. I then used QDir to list all the resources registered with the app, and see all the resources that are expected.

    I added some debugging to the app and where I load the resources into a QPixmap. Sometimes the pixmap loads, is valid, not null, has the width and height expected for the image, and doesn't generate any errors or exceptions, however, the image still does not appear. Other times, QPixmap loads the resource without error, but is null. When null, I use QDir and entryList to validate the resource does in fact exist and is registered.

    Interestingly, one image in the whole app does display, and I have no idea why, but this also helps to demonstrate the generated resource file is being loaded and used.

    Using png and svg images in QAction, QLabel, QPushButton, and QSplashScreen.

    Continue reading...

Compartilhe esta Página