[Qt-interest] QPinchGesture::ScaleFactorChanged: sign reversed on Mac <-> Windows 7?
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Tue Feb 15 18:10:00 CET 2011
Hello,
my Qt application detects QGestures ("pinch") on a QGraphicsScene level: it handles RotationAngleChanged and ScaleFactorChanged. Scaling a given scene item basically works by setting the "distance", like this:
bool ScreenieGraphicsScene::pinchTriggered(const QPinchGesture *gesture)
{
bool result;
QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
...
if (changeFlags & QPinchGesture::ScaleFactorChanged) {
qreal distance = 1.0 - gesture->scaleFactor();
qreal distanceSensitivity = ...; // some factor
emit addDistance(distance * distanceSensitivity);
result = true;
}
return result;
}
(The item is then later on scaled, given its "distance").
On a MacBook Pro running Mac OS 10.6 this works as expected, that is if I "pinch" my fingers apart the item is zoomed in, that is the 'distance' is a negative value ("distance is substracted"), and the actual gesture->scaleFactor() must hence be > 1.0, and when I "pinch" my fingers together the item is zoomed out, that is the 'distance' is a positive value ("more distance is added") and hence gesture->scaleFactor() must be < 1.0.
Also rotation events are recognised just fine.
Note that unlike the example QTDIR\examples\gestures\imagegestures which uses the gesture->property("scaleFactor").toReal() API and some different calculations (and it is running on a plain QWidget as well, not on a QGraphicsScene, which /might/ make a difference, at least for another issue http://bugreports.qt.nokia.com/browse/QTBUG-16281 this was the case...) in my case I am using the (added in Qt 4.7?) gesture->scaleFactor() API.
Now I got a quick chance to run my app on both Windows 7 installation on some Samsung Netbook and a DELL laptop (Windows 7 "Professional" or whatever). On both these platforms the pinch gestures had the opposite effect, "pinching" the fingers together would zoom in the item instead of the (desired) zoom out.
Now I am not sure if it is the Mac Qt implementation or the Windows implementation which somehow changes some sign (maybe my own implementation is also not correct, but the fact that it behaves differently on different Qt platforms tells me that somehow Qt is also involved ;). Also rotation gestures where not recognized at all on Windows 7, even though the "DELL trackpad settings" had rotation gestures enabled. As I said, I only had 5 minutes or so to test...
Off course it could also be the trackpad driver (in general, Gesture support on Windows/DELL laptop seemed to be very... rudimentary, to say the least).
So my first simple question would be: does someone else have experience with QGestures together with QGraphicsScene and both Windows 7 and Mac? Is my interpretation of the gesture->scaleFactor() correct, is it some Qt bug or the trackpad drivers (on both the Samsung Netbook and DELL Laptop?)? Did anyone get consistent behaviour on these platforms?
Qt 4.7.1 MinGW binary distribution on Windows, Qt 4.7.1 binary distribution on Mac.
Thanks, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list