Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
MousePressEvent get the widgetName?
Goffer last edited by Goffer
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 ?
mcosta last edited by
Hi and welcome to devnet,
I'm not sure to fully understand your question.
What do you need? Inside the
mousePressEvent()handler you have full access to the widget data. You can emit a signal and in the slot you can use the
QObject::sender()function to have a pointer to the signal sender.