Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unable to get touch events on QGraphicsView using single touch in Qt5.12.4

Unable to get touch events on QGraphicsView using single touch in Qt5.12.4

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5.12.xqgraphicsviewtouch issue
1 Posts 1 Posters 634 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Himanshu Rohilla
    wrote on 19 Sept 2019, 12:52 last edited by Himanshu Rohilla
    #1

    Hi,

    I create a sample application to get touch events from QGraphicsView using viewport events.

    If I build this application with Qt5.6 then it is working and I can get Touch Begin, Touch Update and Touch End events. But when I compile it with Qt5.12.4, my application is not able to get Touch Update and Touch End events. It only gets Touch Begin.

    This problem is only with single touch. If I use multi touch, then it works fine.

    I share my sample application code.

    #include "GraphicsView.h"
    
    #include <QDebug>
    
    CGraphicsView::CGraphicsView(Widget* wid)
    {
        this->setParent(wid);
    
        this->setGeometry(wid->geometry());
    
        viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
    }
    
    bool CGraphicsView::viewportEvent(QEvent *event)
    {
        qDebug() << "event->type()" << event->type();
    
        switch (event->type()) {
    
        case QEvent::TouchBegin:
        {
            qDebug() << "In touch begin";
        }
            break;
        case QEvent::TouchUpdate:
        {
            qDebug() << "In touch update";
        }
            break;
        case QEvent::TouchEnd:
        {
            qDebug() << "In touch end";
        }
            break;
        default:
            break;
        }
        return QGraphicsView::viewportEvent(event);
    }
    
    

    In the above sample code, "wid" is an object of QWidget class and CGraphicsView class is inherited from QGraphicsView class.

    HImanshu Rohilla

    1 Reply Last reply
    0

    1/1

    19 Sept 2019, 12:52

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved