Displaying a standard icon and text in QLabel

Ram Kumar picture Ram Kumar · May 10, 2012 · Viewed 18.6k times · Source

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.

Answer

mata picture mata · May 13, 2012

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