Search code examples
qtqt4hyperlinkqpixmapqlabel

Qt4: QLabel -> QPixmap -> click to open URL


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.


Solution

  • 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).