[Qt-interest] QTouchEvent/QGestureEvent propagation
Sean Hayes
sean.t.hayes at vanderbilt.edu
Mon Apr 11 16:02:16 CEST 2011
That is an interesting idea. I have no experience using the QObject
parameter in QGestreRecognizer::recognize(). How are you type checking to
insure the object inherits QGraphicsObject? I would suggest using
qobject_cast <http://doc.qt.nokia.com/latest/qobject.html#qobject_cast>instead
of static_cast. What do you do differently within the recognize()
method if the item is not a QGraphicsObject?
On Mon, Apr 11, 2011 at 8:49 AM, Wathek LOUED <wathek at gmail.com> wrote:
> I see Sean thank you so much I had found an other way but it doesn't work
> very well. I thought that since I'm using QGraphicsView/QGrahicsScene and
> QGraphicsObject I could try to cast the "object" in
> QGestreRecognizer::recognize(QGesture *state, QObject *object, QEvent
> *event)
>
> I try to do a static_cast<QGraphicsObject *>(object) and see if the item
> inherits QGraphicsObject if so I get its scene and then I call the
> QGraphicsScene::itemAt function with the QTouchPoint position and I check if
> it's the same item as the casted object or not.
>
> And If the object doesn't inherits QGraphicsObject that means that it's
> probably the scene or the view.
>
> But it seems that there's some fix to do cause it doesn't really work well.
>
>
> On Mon, Apr 11, 2011 at 3:47 AM, Sean Hayes <sean.t.hayes at vanderbilt.edu>wrote:
>
>> I agree, the order the events are received in within the QGraphicsView is
>> counter intuitive.
>>
>> I had a problem similar to this a while ago and I think I solved it by
>> adding a custom property to all my QGraphicsObjects (something link
>> receiveNextGesture). Then within the items I only handled the gesture if
>> that property was true. The property was set through my implementation of
>> QGraphicsView::sceneEvent(). The pseudocode for the sceneEvent() function
>> is:
>>
>> if the event is a QGestureEvent
>>
>> if the gesture has a hotspot
>>
>> itemList = list of all items at the hotspot (see
>> http://doc.qt.nokia.com/latest/qgraphicsview.html#items-2)
>> if itemList.size() >= 1
>>
>> itemList[0]->receiveNextGesture = true
>>
>> for all the rest of the items in the list
>>
>> itemList[iter]->receiveNextGesture = false
>>
>>
>> On Sun, Apr 10, 2011 at 3:33 PM, Wathek LOUED <wathek at gmail.com> wrote:
>>
>>> Hi all,
>>>
>>> I've noticed that the Events in Qt using the
>>> QGraphicsView/QGraphicsScene/QGraphicsItem are spread from the QGraphicsView
>>> then to the QGraphicsScene and the to the item that got the lowest Z-Index
>>> to the most top item.
>>>
>>> I think that that's a bit weird cause generally when using QTouchEvent
>>> and QGesture we look at the most top element so imagine that you programmed
>>> a gesture and that that gesture occured at position (x, y) and in that
>>> position there's 4 items that are grabbing the same gesture, so it'll be
>>> grabbed by all the item and not the top element won't it ?
>>>
>>> I'm trying to find a way to make it grabbed by only the most top element
>>> at the position (x, y) any one could help me for that please ?
>>>
>>> Thank you so much
>>>
>>> Sincerely
>>> W.L
>>>
>>> _______________________________________________
>>> Qt-interest mailing list
>>> Qt-interest at qt.nokia.com
>>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110411/7fd6e33f/attachment.html
More information about the Qt-interest-old
mailing list