Problem with SetIcon when using a png



  • Hello,

    It's my first Post, so I hope I give you all the Informations you need. I am using pyside2 5.13.0 on Python 3.6.5 and install it with pip.

    I write a Tool, where I have some QPushButtons. By User-Action, the displayed Icon has to be updated. I do that as followed:

    /self.values[c_number][cnt].setIcon(QIcon(path))
    

    When I'm using a JPG it's fine. But when I'm using a PNG, it didn't display anything. The Pushbutton turns grey and that is all.

    Have you a suggestion what I can do?
    I have tried the following, without any success:

    self.values[c_number][cnt].repaint()
    self.values[c_number][cnt].setIconSize(QSize(20,20))
    self.values[c_number][cnt].setIconSize(QSize(80,80))
    self.values[c_number][cnt].update()
    

    Best regards

    • Casisto

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Can you display that image on a QLabel ?



  • Thanks.
    The problem stays when I display the image on a QLabel (as Pixmap). JPG are displayed, PNG not.


  • Lifetime Qt Champion

    Can you start the application with the QT_DEBUG_PLUGINS environment variable set to 1 ?

    See what is related to the image plugins.



  • Maybe not. Referring to doc.qt.io/qtforpython there is no Variable named „QT_DEBUG_PLUGINS“ and my shoots in the blue dosn‘t work.



  • I‘ve use now a Build-In PNG2JPG-Converter (Pillow). It‘s very fast and has a good license.

    I‘ll let the Topic open, maybe I got Time to observe the behaviour in some weeks. Now it‘s tracked as „known Issue“


  • Lifetime Qt Champion

    Because the environment variable is described here. The fact that you are using python is of no importance here.


Log in to reply