This is a problem when I want to detect Mouse Events on QLabel Widget. By default, we can not use QLabel to detect Mouse Events on QLabel Widget. If we want to add this feature, we must create a custum QLabel by self. With this tutorial, you can extend to create other QWidget by yourself.
We can detect Mouse Events on QLabel Widget with method mousePressEvent ( QMouseEvent * ev ). For example, I create a class with name labelClick, implement mousePressEvent method with this code :
This is a sample image when start running Mouse Events on QLabel Widget from above code :
And this is a sample output when we click with mouse button over our modification QLabel above :
This is a simple tutorial how to detect Mouse Events on QLabel Widget. You can extend this tutorial to get mouseEvents on other Widget. If you have other method how to detect Mouse Events on QLabel Widget, please share 🙂