How to set image on QPushButton?

前端 未结 8 430
时光说笑
时光说笑 2020-11-30 21:34

I want to set an image on QPushButton, and the size of QPushButton should depend on the size of the image. I am able to do this when using QL

8条回答
  •  一生所求
    2020-11-30 22:08

    You can also use:

    button.setStyleSheet("qproperty-icon: url(:/path/to/images.png);");
    

    Note: This is a little hacky. You should use this only as last resort. Icons should be set from C++ code or Qt Designer.

提交回复
热议问题