PDA

View Full Version : QML Flickable doesn't send all mouse events to unterlaying QGraphicsProxyWidget!



jackmack
15th July 2013, 11:20
Hi all,

Im using Qt 4.8.2 / QtQuick 1.1 on Windows with VS2010.

I want to "show" a complex QGraphicsScene in QML. The goal of the scene is to be like a visual editor where you can select items (e.g. labels) and position them free inside its parent item (circuit board).

When I "expose" the scene/view through QGraphicsProxyWidget and instantiate it in a QML file and loads it via QDeclarativeView it works - I can select/move the items and the implemented C++ function for pinch/pan gestures are working (transfoming the views matrix).

But when I use a QML horizontal flickable (flick from left to right and backwards) and puts the "exposed" scene/view on one of flickables pages then the flickable catches all mouse move events. I can select a scene's item to move it up/down but move it to left/right the flickable begins to flick to next page.

I tried all... overloading QGraphicsScene/View/QGraphicsProxyWidget::mouseMoveEvent(), keyPressEvent(), ... with the result:

mouseMoveEvent() is called few times before the flickable starts.
keyPressEvent() never called.

It seems the flickable doesn't propagate the events to underlaying widgets "exposed" from C++.

But when you implement a simple image viewer with pinch/pan gestures in QML and you are "pinch" on the image the viewer catches the events and works - the flickable doesn't start to flick to next page.

I don't know if that is a flickable bug or I understand something wrong. But I think it's typically to implement the programs logical layer, here a complex scene, in C++ and expose it to QML for displaying it.

Catching all events in QML an sends it explicitly to the "exposed" class needs to much overhead - I can't believe that this is the right solution.

Any ideas? Attached is my current sample program.
Thanks a lot.

9289

jackmack
18th July 2013, 13:31
SOLVED

see http://qt-project.org/forums/viewthread/30007/