Reputation: 784
I'm trying to run two QWidget::mousePressEvent()
handlers at once. I have two widgets, A and B.
B is inherited from QLabel
, A from QWidget
. I have overloaded QWidget::mousePressEvent()
on both of them. Widget from B is getting QPoint
cursor position and it's working.
A widget is getting this information from class B, but unfortunately, only if I click somewhere else outside the widget B (in blue area).
So what should I do to run QWidget::mousePressEvent()
from widget A if I'm clicking on brown space from widget B?
Upvotes: 1
Views: 566
Reputation: 49289
There is event->ignore()
, since A is behind B then presumably A is B's parent (maybe not direct but that doesn't matter as long as it is down the tree), so if in the end of B::mousePressEvent()
you event->ignore()
then the event will continue propagating down and will trigger A's mousePressEvent()
as well... eventually, if nothing else consumes the event down the path.
Also, since presumably the mousePressEvent()
simply invokes some functionality, you could also manually do it from B's event handler for A, all you need is a reference to it, which is trivial to implement. You might have to map coordinates to the parent if they are relevant.
Upvotes: 1