MousePressEvent get the widgetName?
General and Desktop
2
Posts
2
Posters
828
Views
2
Watching
-
Hello !
Today I have implemented my own widget based on QWidget and I added a mousePressEvent so whenever I create this widget, I can click inside and trigger an event. Now I would like that when I click it returns my widgetObjectName.
How could I do that ?I ve seen that maybe I could get the mouse position and then use itemAt()
but it doesn't seem to work for QWidget...Any simple way of doing that ?
Thx
-
Hi and welcome to devnet,
I'm not sure to fully understand your question.
What do you need? Inside themousePressEvent()handler you have full access to the widget data. You can emit a signal and in the slot you can use theQObject::sender()function to have a pointer to the signal sender.