Frederik Gladhorn

Gestures in 4.7.1 behavior change

Published Wednesday October 20th, 2010
5 Comments on Gestures in 4.7.1 behavior change
Posted in Qt | Tags:

Fixing bugs sometimes means changing behavior. The gesture framework is still pretty fresh in Qt. It made its first appearance in Qt 4.6, but only now with Qt 4.7 is it going to be used big time. Sadly we found this bug too late to integrate it into Qt 4.7.0, but it seems important enough to be in 4.7.1.

The pinch gesture has a property that represents the zoom factor. This used to be initialized with the value 0.0 and the total scale factor would be the sum of all scale factors… just like rotations, where the angle is added up.

Well, we admit, that was a bit of a thinking mistake. Scaling is a multiplicative property. So from Qt 4.7.1 on this horrible mistake has been fixed to give you easy to use zooming. We think this is so important that it needs to be in Qt now, since it’s a behavior change and we want to enable Qt to be used on devices.

So if you have a picture and you want to use two fingers to scale it, now all you have to do to make the picture scaling follow the fingers is to multiply the scaling by QPinchGesture::scaleFactor() and you are good ๐Ÿ™‚

So what do we have in QPinchGesture?

  • scaleFactor – whenever you get a gesture event, you can multiply by this value to update your item.
  • totalScaleFactor – this is the scale factor since the beginning of the pinch – if you just care about the final scaling, this is what you want.

The commit in Qt’s 4.7 branch is this one:

e6b2bb6d6a48e722311cd2c5fd86c015eab24b4d

Do you like this? Share it
Share on LinkedInGoogle+Share on FacebookTweet about this on Twitter

Posted in Qt | Tags:

5 comments

2beers says:

Do you know when QML gestures will come out of beta?

Jeremy.Katz says:

@2beers: Labs projects, the QML GestureArea included, aren’t what I would call a beta. It’s something that we think is worth sharing, but there’s no guarantee that it will be officially released as part of Qt.

In this particular case, we think that some sort of gesture support in QML is important to have in Qt (rather than as an add-on), but we don’t have a date in mind. The final form might differ significantly too.

Frederik Gladhorn Frederik Gladhorn says:

We are currently working on some of the internals in Qt to make gesture event delivery play nicer with QGraphicsView and thus also QML. For a real release of the QML GestureArea (the name and api might still change) we hope to have a real release in the first half of next year, of course this is not a promise.

michael says:

Since you fixed the meaning of pinch gesture to be used for zooming, you could have just renamed it to QZoomGesture.

Frederik Gladhorn Frederik Gladhorn says:

@michael: the pinch gesture remains unchaged, so it still contains center point and rotation, which enables you to use it for most two-finger gestures that manipulate one object. It is just that the zooming was not working as we would have expected it. That was fixed.

Commenting closed.

Get started today with Qt Download now