View Full Version : QLabel clickable
bnilsson
29th July 2009, 07:54
How can I make a QLabel clickable?
I am trying to make an About.. dialog with a clickable image without buttons.
wagmare
29th July 2009, 07:57
reimplement mousePressEvent in QLabel class and emit your custom signal
see this link
http://doc.trolltech.com/3.3/qwidget.html#mousePressEvent
yogeshgokul
29th July 2009, 07:58
How can I make a QLabel clickable?
I am trying to make an About.. dialog with a clickable image without buttons.
you have 2 options.
1. Use QPushButton and make them flat, this will give you same feeling like a label is being clicked.
2. Use event filter on label, and react on mousepress event. In this method, you dont need to subclass the QLabel.
bnilsson
29th July 2009, 09:50
Thanks for the advice.
I replaced the QLabel with a big flat QPushButton and used setIcon(pixmap).
I also added the clicked() signal and accept() slot for it in the .ui.
It was the simplest way, works perfectly.
Again, thanks.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.