How to detecting moveEvent in child widget?
-
wrote on 10 Feb 2014, 14:35 last edited by
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 ?
-
wrote on 10 Feb 2014, 17:21 last edited by
i think you must overload the void mouseMoveEvent() inside you QWidget
with something like this
@
protected:
YourWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event);@ -
wrote on 11 Feb 2014, 02:51 last edited by
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?
-
wrote on 15 Feb 2014, 02:12 last edited by
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);
}
@
1/5