2

I have a QLabel without any text but with a QPixmap image. I can not figure out a way to open a url when the user clicks the image. I can not use text in QLabel here.

yolo
  • 2,757
  • 6
  • 36
  • 65

2 Answers2

3

You don't need to put text in, but you do need to switch to either a subclassed label or to use a QPushButton instead. If you use a QPushButton (which is the easiest) then you can change the relief layout so it looks flat again (since the default button doesn't).

Wes Hardaker
  • 21,735
  • 2
  • 38
  • 69
  • Thanks, I set the push button to flat, set the icon as the image, manually set the image size (width, height) and then joined it to the URL opening slot – yolo Apr 04 '11 at 15:04
1

You could install an event filter on the label and filter for mouse press events. For an example, see my answer to a similar question.

Community
  • 1
  • 1
Frank Osterfeld
  • 24,815
  • 5
  • 58
  • 70