bool ReticleHandler::eventFilter(QObject *, QEvent *event) { static bool show = true; switch (event->type()) { case QEvent::TouchBegin: show = true; break; case QEvent::TouchUpdate: show = false; break; case QEvent::TouchCancel: show = false; break; case QEvent::TouchEnd: { if (show) { QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().first(); QPointF fpoint = touchPoint.pos(); int x = static_cast<int>(fpoint.x()); int y = static_cast<int>(fpoint.y()); QPoint point(x,y); emit reticleEvent(point); }; show = false; } break; } return false; }
bool ReticleHandler::eventFilter(QObject *, QEvent *event) { static bool show = true; switch (event->type()) { case QEvent::TouchBegin: show = true; break; case QEvent::TouchUpdate: show = false; break; case QEvent::TouchCancel: show = false; break; case QEvent::TouchEnd: { if (show) { QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().first(); QPointF fpoint = touchPoint.pos(); int x = static_cast<int>(fpoint.x()); int y = static_cast<int>(fpoint.y()); QScreen *primaryScreen = QGuiApplication::primaryScreen(); QTransform lOrientationTranform = primaryScreen->transformBetween(primaryScreen->orientation(), primaryScreen->primaryOrientation(), primaryScreen->geometry()).inverted(); emit reticleEvent(lOrientationTranform.map(QPoint(x,y))); }; show = false; } break; } return false; }