user896036
user896036

Reputation: 509

How we can notify parent window about an occurrence of clicked event in button child class?

I am using mouse press event and clicked event in button class. How I can notify the parent window about the occurrence of this event.

Upvotes: 0

Views: 1058

Answers (2)

alexisdm
alexisdm

Reputation: 29896

You just have to connect the signal clicked() of your button to a slot in your parent class (your question is not so clear).

If you want to pass the click coordinates to the parent, connect the clicked() event to an private slot in your button class, and emit a custom clicked(QPoint) signal with the mouse coordinate (mapFromGlobal(QCursor::pos())) as parameter, and connect that signal in a slot in the parent.

PS: A mouse press event and a click event are not the same thing: if the mouse moves after the press event but before the release event, this is not a click anymore.

Upvotes: 2

Chenna V
Chenna V

Reputation: 10513

You can simply use parentWidget().

Call parentWidget()->mousePressEvent(event) to invoke the parentwidget for the same event

Upvotes: 1

Related Questions