QWheelEvent has fallen a bit behind and needs an update. It was once used for
mouse wheel events only, but is today also used for scroll events generated
from trackpad swipe gestures.
There are two main issues:
* QWheelEvents are either horizontal or vertical, requiring two events and two
calls to update() for a diagonal scroll.
* The delta unit is wheel degrees, high-res trackpads send pixel-based deltas.
To fix this I'd like to deprecate QWheelEvent::delta() and
QWheelEvent::orientation() and add:
QPoint pixelDelta() const
QPoint angleDelta() const
pixelDelta() returns the delta in pixels, if the platform supports it.
angleDelta() returns the same values as delta(), but with both dx and dy values
in the same event. In order to preserve behavior compatibility with Qt 4 we
also need to send "compat" events with the second orientation() and delta().
These will have pixelDelta and angleDelta set to null.
The canonical wheelEvent function will then look like this:
wheelEvent(QWheelEvent *event)
{
if (!event->pixelDelta().isNull()) {
QPoint delta = event->pixelDelta();
…
update();
} else if (!event->angleDelta().isNull()){
QPoint delta = event->angleDelta();
…
update();
}
// else do nothing, this is a Qt 4 compat event.
}
Change-in-progress is at: http://codereview.qt-project.org/#change,12532
Morten
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development