I am coding an android application in QT and when the TouchEvent is emitted my touchEvent->touchPoints().at(newPoint).pos() is always 0,0 until I move my finger and force a TouchUpdate event. Is there a way to get the position on TouchBegin? Below is my event code:
bool event(QEvent* e)
{
switch(e->type())
{
case QEvent::TouchBegin:
touchEvent = static_cast<QTouchEvent*>(e);
emit touchBegin();
emit touchUpdate();
return true;
case QEvent::TouchUpdate:
touchEvent = static_cast<QTouchEvent*>(e);
emit touchUpdate();
return true;
case QEvent::TouchEnd:
emit touchEnd();
return true;
default:
return QWidget::event(e);
}
}
Ok I solved it. I was using the global position when what I needed to use was touchEvent.touchPoints().at(currentPoint).pos().x() or .y() and if it was in a frame or widget I needed to get the global position from that point.