How to detecting moveEvent in child widget?
-
I want to detecting the moveEvent when the Root QWidget is moving.
-
When parent is moved, you would like to receive this event in child object ?
-
i think you must overload the void mouseMoveEvent() inside you QWidget
with something like this
@
protected:
YourWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event);@ -
This answer can partially solve the problem, but only handle the move that triggered by the mouse, because we can also use keyboard to move a QWidget, I want it's child widget also respond to it's movement, how to do that?
-
We can use the following event forward to do that, but there is a problem, the MainWidget should be the Root widget, and sometimes, the childWidget my be dynamic.
So how I do that to add this functional in cihldWidget's constructor or some other place?
@
void MainWidget::moveEvent(QMoveEvent *e)
{
QWidget::moveEvent(e);
QApplication::sendEvent(ui->childWidget, e);
}
@