[Qt-qml] Overlapping MouseAreas / big cursor for recording video

michael.brasser at nokia.com michael.brasser at nokia.com
Mon Aug 30 03:18:41 CEST 2010


On 30/08/2010, at 12:59 AM, ext Cornelius Hald wrote:
> On Sun, 2010-08-29 at 15:55 +0200, Cornelius Hald wrote:
>> MouseArea {
>>    anchors.fill: parent
>>    hoverEnabled: true
>>    acceptedButtons: Qt.RightButton
>>    onMousePositionChanged: {
>>        cursor.x = mouse.x;
>>        cursor.y = mouse.y;
>>    }
>> }
>> 
>> Now this MouseArea is only listening to right-clicks and will pass
>> through the left-clicks to the underlying items.
> 
> I just noticed that now the custom cursor is not following the mouse
> pointer if moved while the left mouse button is pressed. So the result
> doesn't look good if I, for example, flick a list.
> 
> Pointers on how to do that properly would be very welcome :)

There isn't a real good way to do this with MouseArea (that I can see) with the current way mouse grabbing is handled -- basically, if any item accepts a press, it becomes the mouse grabber, and receives the rest of the mouse events until the release (see the Graphics View documentation for more on the details of mouse grabbing).

You could try creating a custom item in C++ that subclasses QDeclarativeItem, uses setFiltersChildEvents to filter all mouse events, and displays a "fake" cursor accordingly. (That might be a cool component for http://developer.qt.nokia.com/wiki/QtQuickOpenComponents, actually)

Regards,
Michael



More information about the Qt-qml mailing list