I have a widget
in center of myWidget
and I used mousePressEvent()
on myWidget
to grab the mouse press event. I want to hide myWidget
on mouse press but not when pressing inside the widget
.
I can calculate the press position by event->windowPos()
which gives a QPointF
and also ui->widget->rect()
which is a QRect
.
how can I check if the QpointF
is inside the QRect
?
Used:
if (ui->widget->geometry().contains(event->pos())) return;
I found another easy way to find if the press event occurred on the widget.
if (ui->widget->underMouse())
doSomething();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With