So I found out about this recently as well, but touch events are not sent to 
QQuickItems on macOS by default, because QNativeGestures are sent instead, due 
to receiving high-precision gestures from the OS itself.

To receive touch events you need to use private API at the moment. Have a look 
at the implementation of

void QQuickMultiPointTouchArea::setTouchEventsEnabled(bool enable)

You would need to get the relevant function pointer and call 
registerTouchWindow on your custom QQuickItem.

On 20 Apr 2017, at 10:59, Nuno Santos 
<nunosan...@imaginando.pt<mailto:nunosan...@imaginando.pt>> wrote:

Alexandru,

Mac OSX, testing with trackpad and mouse.

Regards,

Nuno

On 20 Apr 2017, at 09:36, Alexandru Croitor 
<alexandru.croi...@qt.io<mailto:alexandru.croi...@qt.io>> wrote:

Hi.

What platform are you testing on?


On 20 Apr 2017, at 10:26, Nuno Santos 
<nunosan...@imaginando.pt<mailto:nunosan...@imaginando.pt>> wrote:

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
_______________________________________________
Interest mailing list
Interest@qt-project.org<mailto:Interest@qt-project.org>
http://lists.qt-project.org/mailman/listinfo/interest



_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to