Qt5: fix deprecation warnings of QWheelEvent in Qt 5.15

This commit is contained in:
wmayer
2020-10-18 12:44:23 +02:00
parent f3bdaaa55a
commit 34f4b712d8
8 changed files with 54 additions and 1 deletions

View File

@@ -476,11 +476,21 @@ void ImageView::wheelEvent(QWheelEvent * cEvent)
// Mouse event coordinates are relative to top-left of image view (including toolbar!)
// Get current cursor position relative to top-left of image box
QPoint offset = _pGLImageBox->pos();
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
QPoint pos = cEvent->position().toPoint();
int box_x = pos.x() - offset.x();
int box_y = pos.y() - offset.y();
#else
int box_x = cEvent->x() - offset.x();
int box_y = cEvent->y() - offset.y();
#endif
// Zoom around centrally displayed image point
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
int numTicks = cEvent->angleDelta().y() / 120;
#else
int numTicks = cEvent->delta() / 120;
#endif
if (_invertZoom)
numTicks = -numTicks;