[Interest] How to handle Touch Input on C++ side when extending QQuickItem
Nuno Santos
nunosantos at imaginando.pt
Thu Apr 20 10:26:59 CEST 2017
Hi,
I would like to understand how can I handle a QQuickItem touch input when extending QQuickItem and creating my own item in C++
I can’t find documentation that explains this, neither examples. I have tried the following and none have worked.
What am I missing?
// Implementation
MyItem::MyItem(QQuickItem* parent) :
QQuickItem(parent)
{
setAcceptedMouseButtons(Qt::LeftButton);
setFiltersChildMouseEvents(true);
setKeepTouchGrab(true);
}
// Header
protected:
void mousePressEvent(QMouseEvent *event) {
QQuickItem::mousePressEvent(event);
qDebug() << "mousePressEvent" << event->pos();
}
void mouseMoveEvent(QMouseEvent *event) {
QQuickItem::mouseMoveEvent(event);
qDebug() << "mouseMoveEvent" << event->pos();
}
void mouseReleaseEvent(QMouseEvent *event) {
QQuickItem::mouseReleaseEvent(event);
qDebug() << "mouseReleaseEvent" << event->pos();
}
void mouseReleaseEvent();
void touchEvent(QTouchEvent* event) {
qDebug() << "touch event" << event;
}
bool eventFilter(QObject *, QEvent *event)
{
qDebug() << "processing TouchUpdate...";
if (event->type() == QEvent::TouchUpdate) {
}
// other Touch events here...
return false;
}
Thanks,
Regards,
Nuno
More information about the Interest
mailing list