Fix annoying Qt touch event deprecations for real this time

This commit is contained in:
Nadia Holmquist Pedersen 2024-07-15 14:37:37 +02:00
parent 71f4d7b222
commit 4b17de7e8c
1 changed files with 13 additions and 0 deletions

View File

@ -276,8 +276,13 @@ void ScreenPanel::tabletEvent(QTabletEvent* event)
case QEvent::TabletPress: case QEvent::TabletPress:
case QEvent::TabletMove: case QEvent::TabletMove:
{ {
#if QT_VERSION_MAJOR == 6
int x = event->position().x();
int y = event->position().y();
#else
int x = event->x(); int x = event->x();
int y = event->y(); int y = event->y();
#endif
if (layout.GetTouchCoords(x, y, event->type()==QEvent::TabletMove)) if (layout.GetTouchCoords(x, y, event->type()==QEvent::TabletMove))
{ {
@ -302,8 +307,10 @@ void ScreenPanel::tabletEvent(QTabletEvent* event)
void ScreenPanel::touchEvent(QTouchEvent* event) void ScreenPanel::touchEvent(QTouchEvent* event)
{ {
#if QT_VERSION_MAJOR == 6
if (event->device()->type() == QInputDevice::DeviceType::TouchPad) if (event->device()->type() == QInputDevice::DeviceType::TouchPad)
return; return;
#endif
event->accept(); event->accept();
@ -311,9 +318,15 @@ void ScreenPanel::touchEvent(QTouchEvent* event)
{ {
case QEvent::TouchBegin: case QEvent::TouchBegin:
case QEvent::TouchUpdate: case QEvent::TouchUpdate:
#if QT_VERSION_MAJOR == 6
if (event->points().length() > 0) if (event->points().length() > 0)
{ {
QPointF lastPosition = event->points().first().lastPosition(); QPointF lastPosition = event->points().first().lastPosition();
#else
if (event->touchPoints().length() > 0)
{
QPointF lastPosition = event->touchPoints().first().lastPos();
#endif
int x = (int)lastPosition.x(); int x = (int)lastPosition.x();
int y = (int)lastPosition.y(); int y = (int)lastPosition.y();