PDA

View Full Version : customize Swipe gesture for single touch



SSqt5.2
5th December 2014, 11:07
Hi All,
working with embedded Linux Qt for customizing the swipe gesture for single touch.
I have copied the SwipeGesture_Recongnizer function in my_widget.cpp class file and modified it to operate on single touch only.

"QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event);"

i have copied the above function from this path:
https://qt.gitorious.org/qt/qt/source/4c400ec8e397b4da9898f96c50a702eaa362293d:src/gui/kernel/qstandardgestures.cpp#L42

i have included
#include <QWidget>
#include <QImage>
#include <QtGui>
#include <QGesture>
#include <QLabel>
#include <QGestureRecognizer>
#include <QSwipeGesture> in my file.

for compiling the error is ""
D:\Qt_S_Projects\Qt_Flick1\imagewidget.h:45: error: 'QSwipeGestureRecognizer' has not been declared
QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,)


Can any one please tell how to customize the SwipeGestureRecognizer function , or files need to be included?

Thanks in advance.

anda_skoa
5th December 2014, 15:17
I wonder what operating system you are using as a developer workstation if it doesn't even come with tools to search in text files :)

This class is declared in a private header:
qtbase/src/widgets/kernel/qstandardgestures_p.h

Cheers,
_

SSqt5.2
8th December 2014, 04:09
Hi Anda_Skoa,
Thanks for reply..
I am using windows desktop Qt 5.2 Open-source version, mingw48_32 compiler.

I checked the file, it is present at above mentioned path. and I included the file as below,
“#include "C:\Qt\Qt5.2.0\5.2.0\Src\qtbase\src\widgets\kernel\ qstandardgestures_p.h"”

If I compile the program with this file included, there is one more file to be provided
“#include "private/qgesture_p.h"” which is included in qstandardgestures_p.h file.
What is supposed to be included in private/qgesture_p.h file?

I am bit confused with the following Guideline mentioned in Qt documentation. Please help to understand and Implement.
http://qt-project.org/doc/qt-4.8/qgesturerecognizer.html
"To add support for new gestures, you need to derive from QGestureRecognizer to create a custom recognizer class, construct an instance of this class, and register it with the application by calling QGestureRecognizer::registerRecognizer(). "
I have created a image widget which is enabled to receive the gestures. As per above statement, should I declare the element of “” class as a member of the custom widget?
Any help or suggested documentation for this?

Thanks in advance.

anda_skoa
8th December 2014, 10:46
Which part of the instructions do you have problems with?

- create a subclass of QGestureRecognizer

class YourGestureRecognizerClass : pubic QGestureRecognizer { ... };


- create an instance of that class


YourGestureRecognizerClass *a = new YourGestureRecognizerClass();


- register it

QGestureRecognizer::registerRecognizer(a);


Cheers,
_