Le dimanche 8 février 2015, 17:39:16 Leonardo Zide a écrit :
> The zoom amount isn't affected by the current model, it's
> always the same amount.
Sorry, just an affirmative sentence I turned into a negative
after after I thought of testing with a lone 1x1 brick. Should
have deleted it altogether.
> I just tried both the mouse wheel and
> the trackpad to zoom and I don't see anything like that (Qt4,
> Windows).
Confirmed: Qt4 is Ok, Qt5 is stuttering.
I tested other Qt5 applications with zoom on mouse wheel: they
are fine.
By curiosity, I checked the code of one of them: Stellarium.
First, they still use event->delta() with Qt >= 5.2.0. That
the function has been obsoleted doesn’t seem to make it non-
working for them. (Which should be expected: if the function
doesn’t work anymore, it should be completely removed from the
API/ABI, not hanging around doing nothing.) So I reverted
r.1765 and event->delta() still works in Qt5.
Well, was it really non functionning in r.1763/Qt5 and did I
just not scrolled enough (didn’t seem to me I didn’t tried
enough at the time), or did something else changed (doesn’t look
like it though)....
Second, their handling of wheelevents is way more complex:
they use a timer and an accumulator to reduce the number of
events to handle. It’s mainly a fix for the Qt bug 22269 (
https://bugreports.qt.io/browse/QTBUG-22269 ). That bug seems
to be confined to OS X and is about scrolling improperly
continuing. This is not exactly the problem I have.
Nevertheless, I thought about the problem of low delta values
and hacked an accumulator (diff attached) and ... it works!
What I think happens is that Qt5 generates more WheelEvents,
with lower delta values (< 120), which precludes them to having
an effect.
--
Sylvain Sauvage
Index: qt/lc_qglwidget.cpp
===================================================================
--- qt/lc_qglwidget.cpp (révision 1777)
+++ qt/lc_qglwidget.cpp (copie de travail)
@@ -304,6 +304,8 @@
void lcQGLWidget::wheelEvent(QWheelEvent *event)
{
+ static int delta_acc = 0;
+ delta_acc += event->delta();
float scale = deviceScale();
widget->mInputState.x = event->x() * scale;
@@ -312,15 +314,13 @@
widget->mInputState.Shift = (event->modifiers() & Qt::ShiftModifier) != 0;
widget->mInputState.Alt = (event->modifiers() & Qt::AltModifier) != 0;
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
- int numDegrees = event->angleDelta().y() / 8;
-#else
- int numDegrees = event->delta() / 8;
-#endif
- int numSteps = numDegrees / 15;
+ if (delta_acc >= 120 || delta_acc <= -120)
+ {
+ int numSteps = delta_acc / 120;
+ widget->OnMouseWheel(numSteps);
+ delta_acc = 0;
+ }
- widget->OnMouseWheel(numSteps);
-
event->accept();
}
_______________________________________________
Leocad mailing list
[email protected]
https://list.gerf.org/listinfo/leocad