Get mouse position in child QGraphicsScene
<p>In Qt5, I have a main window with a scene:</p>

<pre><code>MyWindow::MyWindow(QWidget *parent) : QMainWindow(parent)
{
    view = new QGraphicsView();
    scene = new QGraphicsScene();
    scene-&gt;installEventFilter(this);
    view-&gt;setScene(scene);
    ...
    setCentralWidget(view);
}
</code></pre>

<p><code>view</code> and <code>scene</code> are both private members of <code>MyWindow</code>. <strong>I want to know, in the <code>MyWindow</code> class,  the mouse position when I click on the scene.</strong> That's why I use <code>installEventFilter</code> above. And I have tried to catch the event with this:</p>

<pre><code>bool MyWindow::eventFilter(QObject *target, QEvent *event)
{
    if (target == scene)
    {
        if (event-&gt;type() == QEvent::GraphicsSceneMousePress)
        {
            const QGraphicsSceneMouseEvent* const me = static_cast&lt;const QGraphicsSceneMouseEvent*&gt;(event);
            const QPointF position = me-&gt;pos();
            cout &lt;&lt; position.x() &lt;&lt; "," &lt;&lt; position.y() &lt;&lt; endl;
        }
    }
    return QMainWindow::eventFilter(target, event);
}
</code></pre>

<p>This code does not work as expected: The position it prints when I click on the scene is always 0,0. Any clue about what is wrong?</p>