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. Qt 5.12 Unable To Get Touch Events
Forum Updated to NodeBB v4.3 + New Features

Qt 5.12 Unable To Get Touch Events

Scheduled Pinned Locked Moved Unsolved General and Desktop
touchtouch screentouchscreenmouse pressmousepressevent
4 Posts 3 Posters 782 Views 1 Watching
  • 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.
  • D Offline
    D Offline
    duhanayan
    wrote on 18 Jan 2024, 13:44 last edited by duhanayan
    #1

    I am working on very complicated Qt project. I have a GL screen on my app and I want it to be zoomed in/out with touch screen moves. But unfortunetly I can't handle touch events.

    I added a line to accept touch events to my constructor.

    setAttribute(Qt::WA_AcceptTouchEvents, true);
    

    And here is my event function under protected that I print events that happened.

    class MyWidget: public QGLWidget
    {
    	Q_OBJECT
    protected:
    		bool event(QEvent *event) override
    	{
    	    // Print the event type
    	    qDebug() << "Event Type: " << event->type();
    
    	    if (event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate || event->type() == QEvent::TouchEnd) {
    	        QTouchEvent *touchEvent = static_cast<QTouchEvent*>(event);
    
    	        QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
    
    	        if (touchPoints.count() == 2) {
    	            QTouchEvent::TouchPoint touchPoint1 = touchPoints.at(0);
    	            QTouchEvent::TouchPoint touchPoint2 = touchPoints.at(1);
    
    	            qDebug() << "Touch 1: " << touchPoint1.pos();
    	            qDebug() << "Touch 2: " << touchPoint2.pos();
    	        }
    	        return true;
    	    }
    	    return QWidget::event(event);
    	}
    

    And I added this line to my main function:

    app.setAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents);
    

    When I try to touch from touch screen, what printed in output is QEvent::MouseButtonPress.

    So anyone know what to do, I would be grateful.

    A 1 Reply Last reply 19 Jan 2024, 18:28
    0
    • D duhanayan
      18 Jan 2024, 13:44

      I am working on very complicated Qt project. I have a GL screen on my app and I want it to be zoomed in/out with touch screen moves. But unfortunetly I can't handle touch events.

      I added a line to accept touch events to my constructor.

      setAttribute(Qt::WA_AcceptTouchEvents, true);
      

      And here is my event function under protected that I print events that happened.

      class MyWidget: public QGLWidget
      {
      	Q_OBJECT
      protected:
      		bool event(QEvent *event) override
      	{
      	    // Print the event type
      	    qDebug() << "Event Type: " << event->type();
      
      	    if (event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate || event->type() == QEvent::TouchEnd) {
      	        QTouchEvent *touchEvent = static_cast<QTouchEvent*>(event);
      
      	        QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
      
      	        if (touchPoints.count() == 2) {
      	            QTouchEvent::TouchPoint touchPoint1 = touchPoints.at(0);
      	            QTouchEvent::TouchPoint touchPoint2 = touchPoints.at(1);
      
      	            qDebug() << "Touch 1: " << touchPoint1.pos();
      	            qDebug() << "Touch 2: " << touchPoint2.pos();
      	        }
      	        return true;
      	    }
      	    return QWidget::event(event);
      	}
      

      And I added this line to my main function:

      app.setAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents);
      

      When I try to touch from touch screen, what printed in output is QEvent::MouseButtonPress.

      So anyone know what to do, I would be grateful.

      A Offline
      A Offline
      Axel Spoerl
      Moderators
      wrote on 19 Jan 2024, 18:28 last edited by
      #2

      @duhanayan said in Qt 5.12 Unable To Get Touch Events:

      AA_SynthesizeTouchForUnhandledMouseEvents

      That is a known bug, unfortunately.
      It won´t be fixed in 5.12, but everything works in Qt 6.

      Software Engineer
      The Qt Company, Oslo

      C 1 Reply Last reply 19 Jan 2024, 18:36
      0
      • A Axel Spoerl
        19 Jan 2024, 18:28

        @duhanayan said in Qt 5.12 Unable To Get Touch Events:

        AA_SynthesizeTouchForUnhandledMouseEvents

        That is a known bug, unfortunately.
        It won´t be fixed in 5.12, but everything works in Qt 6.

        C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 19 Jan 2024, 18:36 last edited by
        #3

        @Axel-Spoerl So you can close the bug :)

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        A 1 Reply Last reply 19 Jan 2024, 19:00
        1
        • C Christian Ehrlicher
          19 Jan 2024, 18:36

          @Axel-Spoerl So you can close the bug :)

          A Offline
          A Offline
          Axel Spoerl
          Moderators
          wrote on 19 Jan 2024, 19:00 last edited by
          #4

          @Christian-Ehrlicher
          Done, Sir :-)
          I was just not sure, whether the fix happened in 5.15 or 6.2.
          The latter it is.

          Software Engineer
          The Qt Company, Oslo

          1 Reply Last reply
          2

          4/4

          19 Jan 2024, 19:00

          • Login

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