Hi,
Here is the code I have used to capture events.
setAttribute(Qt::WA_AcceptTouchEvents,true);
bool CMainWindow::event(QEvent *ev)
{
int t = ev->type();
switch (t) {
case QEvent::MouseButtonPress:
qDebug()<<"Mouse button pressed";
break;
case QEvent::TouchBegin:
qDebug()<<"Touch Begin";
break;
case QEvent::MouseButtonDblClick:
qDebug()<<"Mouse button dbl click";
break;
case QEvent::MouseButtonRelease:
qDebug()<<"Mouse button release";
break;
case QEvent::TouchUpdate:
qDebug()<<"Touch Update";
break;
case QEvent::TouchCancel:
qDebug()<<"Touch Cancel";
break;
case QEvent::TouchEnd:
qDebug()<<"Touch End";
break;
}
if(t == QEvent::TouchBegin)
{
ev->accept();
return true;
}
else
return QWidget::event(ev);
}
void CMainWindow:n_lbl_i_clicked()
{
qDebug()<<"Click Signal Emitted";
}
void CMainWindow:n_lbl_i_pressed()
{
qDebug()<<"Press Signal Emitted";
}
Debug Logs of app when I press or click on button using mouse :-
Press Signal Emitted
Click Signal Emitted
Debug Logs of app when I press or click on button using touch :-
Touch Begin
Touch Update
Mouse button pressed
Touch Update
Touch Update
Touch Update
Touch Update
Touch End
Mouse button release
Also, I am getting mouse cursor on my application screen and it moves smooth everywhere and emits the click() and press() signal, If I click or press QPushbutton. The same aren't working using touch.
Thanks
Bookmarks