Talk:Custom Swipe Gestures in Qt

From Nokia Developer Wiki
Jump to: navigation, search
04 Apr
Article Review by hamishwillee (20110404)


I like this article - very useful. I've given it a subedit and renamed it, primarily to make it obvious that this is about working around a bug, but also that the information on custom recognisers will still remain useful even when the bug is fixed.

Would it be possible to attach a zip file showing a fully working recogniser and test code? This would be really helpful for anyone trying your code.

I've also marked it as reviewer approved because it gives a clear example of a particular problem and a workaround.


DoubleClick Event

Very nice works great on my e7-00, however i've come to a problem. when i double click anywhere (but the two clicks on the same place) it recognises a swipe. even the positions of the clicks are different (first always zero, second anywhere.) i'm trying to find a workaround but i'm a beginner.. maybe someone sees the problem?

EDIT: found a solution don't know if it's optimal:

public: bool dbcl;
SwipeGestureRecognizer::recognize(QGesture *pGesture, QObject *pWatched, QEvent *pEvent){
case QEvent::MouseButtonPress:{ ....} break;
case QEvent::MouseButtonDblClick:{
case (QEvent::MouseButtonRelease):{
dbcl= false;
else{ ...normal function..}

Sheenu -

yes please provide a zip file showing how to implement this fully. It would be very helpful to everyone (Especially me :) ) Thanks in advance!

Sheenu 09:23, 11 April 2012 (EEST)

Bootchk - custom swipe gesture: typedef parent

Your "typdef QGestureRecognizer parent" is poor practice and confusing. You use "parent" in several different ways: to mean superclass, and to mean parentWidget. I suspect your example might not even work, where you call "parent::event()."

bootchk 16:40, 15 April 2012 (EEST)

Bootchk - custom swipe gesture: real custom gesture

Your example replaces the default recognizer for an existing gesture.

More generally, if we were defining a custom gesture, wouldn't your code (below) be backwards?



  // Create a SWIPE recognizer because the default SWIPE recognizer
  // does not really work on Symbian device.
  QGestureRecognizer* pRecognizer = new SwipeGestureRecognizer();
  m_gestureId = QGestureRecognizer::registerRecognizer(pRecognizer);

In other words, calling registerRecognizer() returns a custom gesture type ID which would be needed as parameter to grabGesture()? Here you don't need the m_gestureId because you already know it is the ID for SwipeGesture. More generally wouldn't you need:

I'm not trying to be critical, and I could be wrong, I'm just trying to understand.

bootchk 18:19, 15 April 2012 (EEST)

Hamishwillee - The author wrote this a year ago and may no longer we watching!

I suggest you send them a private message (hover over their username) and point them to this wiki page/thread. That way they have a greater chance of getting notified of these questions.



hamishwillee 04:18, 16 April 2012 (EEST)