开发者

QGraphicsView accepted events

I am using the Qt Graphics View framework to create a scene and attach multiple views to the same scene, where these views render a 3D openscenegraph scene as background and the 2D drawings are kind of overlays.

I am trying to intercept mouse/key events in my OverlayViewport class (inherits QGraphicsView) and navigate the 3D scene accordingly. Below is a sample event handler:

void OverlayViewport::mouseMoveEvent( QMouseEvent * event )
{开发者_开发技巧
    QGraphicsView::mouseMoveEvent(event);
    if (event->isAccepted())
    {
        return;
    }

    3D_Scene_Stuff_Code();
}

But the events are always accepted, therefore my 3D scene stuff code never executes. If I remove the isAccepted() check, my code always executes.

What i want to achieve is, let the scene do its stuff like selection, dragging vs, and if it does not do anything (does not accept the event), do my 3D stuff.

so, here are my questions:

1 - Am I on the wrong path here?

2 - Should I forward the events to the scene that the view is attached and do my stuff if event is not accepted by the scene?

3 - If not 2, how should I proceed?

Best Regards.


I found the culprit. It seems that this was a bug in Qt. QGraphicsView does not set the accepted flag of mouseMoveEvents appropriately. This happens for mouseMoveEvents only, the other events are fine. It is reported to Qt and waiting to be fixed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜