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.
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).
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.
精彩评论