[Interest] How to handle Touch Input on C++ side when extending QQuickItem

Nuno Santos nunosantos at imaginando.pt
Thu Apr 20 10:59:48 CEST 2017


Alexandru,

Mac OSX, testing with trackpad and mouse.

Regards,

Nuno

> On 20 Apr 2017, at 09:36, Alexandru Croitor <alexandru.croitor at qt.io> wrote:
> 
> Hi.
> 
> What platform are you testing on?
> 
> 
>> On 20 Apr 2017, at 10:26, Nuno Santos <nunosantos at 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 at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
> 




More information about the Interest mailing list