Replace usage of deprecated QWheelEvent members

This commit is contained in:
Dale Glass 2022-06-05 13:23:25 +02:00
parent 044f08b931
commit 8a12bf1749
2 changed files with 14 additions and 11 deletions

View file

@ -173,9 +173,13 @@ bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event)
case QEvent::Wheel: {
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
QPointF transformedPos = mapToVirtualScreen(wheelEvent->pos());
QWheelEvent mappedEvent(transformedPos, wheelEvent->delta(), wheelEvent->buttons(), wheelEvent->modifiers(),
wheelEvent->orientation());
QPointF transformedPos = mapToVirtualScreen(wheelEvent->position());
QWheelEvent mappedEvent(transformedPos, wheelEvent->globalPosition(), wheelEvent->pixelDelta(), wheelEvent->angleDelta(),
wheelEvent->buttons(), wheelEvent->modifiers(), wheelEvent->phase(),
wheelEvent->inverted(), wheelEvent->source());
mappedEvent.ignore();
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
return mappedEvent.isAccepted();

View file

@ -27,25 +27,24 @@ WheelEvent::WheelEvent() :
isMeta(false),
isAlt(false)
{
}
WheelEvent::WheelEvent(const QWheelEvent& event) {
x = event.x();
y = event.y();
delta = event.delta();
if (event.orientation() == Qt::Horizontal) {
x = event.position().x();
y = event.position().y();
if (event.angleDelta().x() != 0) {
orientation = "HORIZONTAL";
} else {
orientation = "VERTICAL";
}
// button pressed state
isLeftButton = (event.buttons().testFlag(Qt::LeftButton));
isRightButton = (event.buttons().testFlag(Qt::RightButton));
isMiddleButton = (event.buttons().testFlag(Qt::MiddleButton));
// keyboard modifiers
isShifted = event.modifiers().testFlag(Qt::ShiftModifier);
isMeta = event.modifiers().testFlag(Qt::MetaModifier);