Alex Rivera | Logout

Displaying a standard icon and text in QLabel

Asked 2012-05-10T12:19:19.827
15

I want to display a standard warning icon along with some description text in QLabel in pyqt. Qlabel doesn't have setIcon function. So how could I do that?

Any help would be appreciated.

Edit
Report

1 Answer

24

QLabel doesn't have a setIcon method, but it has setPixmap. But if you use that to set a QPixmap it overrides your text. but there are a few possibilities to achieve what you want:

  • use the html-capabilities of the QLabel to display text+image
  • use two labels, one with the text and one with the image
  • paint the component yourself
answered 2012-05-13T20:06:59.657

Your Answer