Results 1 to 4 of 4

Thread: How to set Qt::GestureType for my specific gesture?

  1. #1
    Join Date
    Jul 2010
    Posts
    53
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to set Qt::GestureType for my specific gesture?

    Title says pretty much what i need. Can't find the way to recognize 2 different user defined gestures. What am i doing wrong? The only useful resource i found so far was this link.

    Thank You.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to set Qt::GestureType for my specific gesture?

    QGestureRecognizer::registerRecognizer() returns a value that can be used as Qt::GestureType. Be sure to carefully read the docs for Qt::GestureType!
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    GreenScape (11th October 2011)

  4. #3
    Join Date
    Jul 2010
    Posts
    53
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set Qt::GestureType for my specific gesture?

    Thank you very much! That's exactly what I was looking for. I haven't read carefully I guess :|

  5. #4
    Join Date
    Apr 2012
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to set Qt::GestureType for my specific gesture?

    I am also trying to implement a custom gesture, with a custom gesture object inheriting QGesture.

    If registerRecognizer() returns a gesture type ID, then should that be passed to grabGesture(gestureTypeID) ? One example showed the grabGesture() call before the registerRecogizer() call. Possibly that example was wrong, or possibly it only works when the gesture type is a built-in gesture. (The example shows how to reimplement QPanGesture to fix a non-working version on some platforms.)

    My understanding of the sequence: calling registerRecognizer() invokes the create() method of the recognizer, which creates a gesture of a certain class (in this case a custom gesture). The document says the ID is "generated" which means it is somewhat arbitrary for custom gestures (a bitwise OR of QCustomGesture and other arbitrary bit)? I assume that the gestureID is passed to the gesture constructor, otherwise, how would it know? So, a custom gesture should not reimplement the gestureType() method, that should all be hidden? A call to gestureType() will return the ID assigned to the gesture when it is created() by the recognizer?

    But the rest of your application (the gestureEvent handlers) needs to know the gesture ID, so when it is returned by registerRecognizer() the app should store it in a global variable? It is not defined at compile time.

    This is all speculative. Currently my Python Pyside Qt code is crashing in the gestureType() method of my custom gesture (whether I reimplement it or not, and whether my custom gesture inherits from QGesture or QPanGesture) ! I am installing Qt 4.8 to insure it is not a bug already fixed.

    I am also confused about the "parent" parameter of a QGesture constructor. I presume it is a parent Widget. It defaults to None, which is the case when a gesture instance is first created when registerRecognizer is called? I presume later, on the call to grabGesture() the Qt framework changes the parent property to be the widget that is grabbing. Or later, when a raw input event is in a widget that has grabbed a gesture, the framework sets the parent of the gesture?

    The Qt documentation is rather good, but very abstract and subtle: you must read it carefully. So far it is eluding me. It is a good thing the source is open.

Similar Threads

  1. Swipe gesture not recognized
    By Luc4 in forum Qt Programming
    Replies: 2
    Last Post: 16th December 2014, 15:13
  2. Replies: 5
    Last Post: 14th February 2011, 14:06
  3. Gesture Programming specs
    By scarleton in forum Qt Programming
    Replies: 3
    Last Post: 5th December 2010, 23:30
  4. Replies: 0
    Last Post: 18th November 2010, 16:48
  5. Qt Pinch Gesture Support
    By Peter_APIIT in forum Qt Programming
    Replies: 1
    Last Post: 8th January 2010, 19:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.