Qt Buttons: How to give button properties to an image.
I intend to give button properties like clicked, released etc to some images so it behaves like buttons.
I see many types of button widgets. Could you please help in suggestion if there's any specific widget which i can link to my images to have button properties.?
Also, can it be done in both qml and c++?
Thanks in advance.
yes there is, for qml and widgets, for both cases there are multiple ways to do it.
I'll list the easiest method for both
QML: Make your own Item/QMl File containing an Image and a MouseArea object -> done
QWidget: Subclass QLabel, and overrite mouse events -> implement logic for when to emit clicked, released and pressed.
Even so its far from perfect, the wiki article should help: https://wiki.qt.io/Clickable_QLabel
@J.Hilk Thanks a lot mate. That is very precise and helpful.