[Qt-interest] Thoughts about QGestures
Denis Dzyubenko
shadone at gmail.com
Wed May 19 17:47:32 CEST 2010
Hi,
On 18 May 2010 08:50, Guido Seifert <Wargand at gmx.de> wrote:
> yesterday I played a bit with QGestures. When I tried to run the imagegestures examples I was at first very surprised that it did nothing for me. Somehow I expected that though I have no touch screen it had to work with mouse also. After some 'research' I found that QMouseEvents and QTouchEvents are two totally different things.
>
> Nevertheless, after some googling I found that I am not the only one who fell into this trap. So I'd recomment to make the documentation a little bit more clear there.
>
> Furthermore, would it be impossible to 'enhance' QSwipeEvents and QPanEvents so that they work using QMouseEvents and QTouchEvents? I am well aware that there are limits to the interchangeability of mouse and touchscreen usage, but at least for single touch gestures it should be possible. I see no general problem that e.g. the QSwipeEvent could not be sent when I swipe with the mouse pointer.
yes, that is definitely possible - you can implement your own gesture
recognizer that will produce either the existing QPanGestures or your
own CustomPanGesture objects.
You can do something like this:
class MyPanRecognizer : public QGestureRecognizer
{
public:
QGesture* create(QObject* ) { return new QPanGesture; }
QGestureRecognizer::Result recognizer(QGesture *g, QObject *, QEvent *e)
{
if (e->type() == QEvent::MouseMove) return
QGestureRecognizer::TriggerGesture;
if (e->type() == QEvent::MouseButtonRelease) return
QGestureRecognizer::FinishGesture;
return QGestureRecognizer::Ignore;
}
};
then register it in Qt:
QGestureRecognizer::registerRecognizer(new MyPanRecognizer);
> This would have the advantage that an application, which was developed for touch screens would automatically also work for desktops using a mouse.
>
> If you Trolls want to keep your swipe/pan events as simple and clean as it is now, which certainly would be a very reasonable decision, would it be at least possible that you could provide a QMouseSwipeEvent/QMousePanEvent? This would also easily allow to write apps, which make no difference between mouse and touch screen gestures.
--
Best regards,
Denis.
More information about the Qt-interest-old
mailing list