Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QT 5.4 widget touch event
Forum Updated to NodeBB v4.3 + New Features

QT 5.4 widget touch event

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
7 Posts 2 Posters 1.4k 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.
  • E Offline
    E Offline
    elliottal
    wrote on last edited by
    #1

    Hello,

    I am running the broadcast sender widget example and I am trying to enable touch events for the widget.
    I have installed tslib library and ran ts_calibrate and ts_test to calibrate and verify the touch screen is working properly which it is.

    I have set up the environment variables for the tslib which are:
    TSLIB_CONFILE=/etc/ts.conf
    TSLIB_CALIBFILE=/etc/pointercal
    TSLIB_CONSOLEDEVICE=none
    TSLIB_tseventtype=INPUT
    TSLIB_FBDEVICE=/dev/fb0
    TSLIB_TSDEVICE=/dev/input/event0
    TSLIB_PLUGINDIR=/usr/lib/ts

    I have also set up the QT environment variables:
    QT_PLUGIN_PATH=/usr/lib/plugins
    QT_QPA_FONTDIR=/usr/lib/fonts
    QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/plugins/platforms
    QT_QPA_PLATFORM=linuxfb
    QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event0

    I went to the constructor for the widget and set the "setAttribute(Qt::WA_AcceptTouchEvents)"

    right now I am just trying to see if the touch events are being registered. I set up a mousePressEvent method to see the mouse events which worked fine:

    void Sender::mousePressEvent(QMouseEvent *event){
       if(event->button() == Qt::LeftButton){
           qDebug() << "left mouse click";
    } else {
           //do something
       }
    }
    

    when i run the application with the above code and when i click the left mouse button on the widget I see "left mouse click" in the application output so I am trying to do something similar with the touch events and set up an event filter:

    void Sender::eventFilter(QTouchEvent *event){
       if(event->type() == QTouchEvent::TouchBegin){
         qDebug() << "touch event";
    } else {
       //do something
       }
    }
    

    however I have yet to see anything on the application output. I have read various other threads looking for a solution but have not been able to find one yet. any help would be appreciated

    raven-worxR 1 Reply Last reply
    0
    • E elliottal

      Hello,

      I am running the broadcast sender widget example and I am trying to enable touch events for the widget.
      I have installed tslib library and ran ts_calibrate and ts_test to calibrate and verify the touch screen is working properly which it is.

      I have set up the environment variables for the tslib which are:
      TSLIB_CONFILE=/etc/ts.conf
      TSLIB_CALIBFILE=/etc/pointercal
      TSLIB_CONSOLEDEVICE=none
      TSLIB_tseventtype=INPUT
      TSLIB_FBDEVICE=/dev/fb0
      TSLIB_TSDEVICE=/dev/input/event0
      TSLIB_PLUGINDIR=/usr/lib/ts

      I have also set up the QT environment variables:
      QT_PLUGIN_PATH=/usr/lib/plugins
      QT_QPA_FONTDIR=/usr/lib/fonts
      QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/plugins/platforms
      QT_QPA_PLATFORM=linuxfb
      QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event0

      I went to the constructor for the widget and set the "setAttribute(Qt::WA_AcceptTouchEvents)"

      right now I am just trying to see if the touch events are being registered. I set up a mousePressEvent method to see the mouse events which worked fine:

      void Sender::mousePressEvent(QMouseEvent *event){
         if(event->button() == Qt::LeftButton){
             qDebug() << "left mouse click";
      } else {
             //do something
         }
      }
      

      when i run the application with the above code and when i click the left mouse button on the widget I see "left mouse click" in the application output so I am trying to do something similar with the touch events and set up an event filter:

      void Sender::eventFilter(QTouchEvent *event){
         if(event->type() == QTouchEvent::TouchBegin){
           qDebug() << "touch event";
      } else {
         //do something
         }
      }
      

      however I have yet to see anything on the application output. I have read various other threads looking for a solution but have not been able to find one yet. any help would be appreciated

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @elliottal
      not every touchscreen (actually its driver) produces touch events but only mouse events

      also on which object did you install the event filter? you should install it on the qApp instance to make sure.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • E Offline
        E Offline
        elliottal
        wrote on last edited by elliottal
        #3

        in the broadcastsender example I installed the eventFilter on the startButton and quitButton Objects.

        startButton->installEventFilter(this)
        quitButton->installEventFilter(this)
        

        forgive me but I am very new to Qt and am not sure where to install the eventfilter on the qApp instance. How would I go about installing it on the qApp instance?

        raven-worxR 1 Reply Last reply
        0
        • E elliottal

          in the broadcastsender example I installed the eventFilter on the startButton and quitButton Objects.

          startButton->installEventFilter(this)
          quitButton->installEventFilter(this)
          

          forgive me but I am very new to Qt and am not sure where to install the eventfilter on the qApp instance. How would I go about installing it on the qApp instance?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @elliottal said in QT 5.4 widget touch event:

          How would I go about installing it on the qApp instance?

          qApp->installEventFilter(..);
          

          This way you will filter every events before it is sent to any widget/object.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • E Offline
            E Offline
            elliottal
            wrote on last edited by
            #5

            I installed the eventFilter as you suggested and added the following line of code to the constructor

            qApp->installEventFilter(this);
            

            I implemented the event filter function as shown below so that I can see any events passed to the app.

            bool Sender::eventFilter(QObject *target, QEvent *event){
                qDebug() << "event received" << target->metaObject()->className() << event->type();
                return false;
            }
            

            however I am still not seeing anything displayed showing the touch events are being sent to QT and displayed on the application output. Is this not enough to see touch events from the touch screen or should I be able to see touch events displayed with that?

            raven-worxR 1 Reply Last reply
            0
            • E elliottal

              I installed the eventFilter as you suggested and added the following line of code to the constructor

              qApp->installEventFilter(this);
              

              I implemented the event filter function as shown below so that I can see any events passed to the app.

              bool Sender::eventFilter(QObject *target, QEvent *event){
                  qDebug() << "event received" << target->metaObject()->className() << event->type();
                  return false;
              }
              

              however I am still not seeing anything displayed showing the touch events are being sent to QT and displayed on the application output. Is this not enough to see touch events from the touch screen or should I be able to see touch events displayed with that?

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @elliottal
              as i already stated in my first post.
              make sure that it actually sends touch events.
              Read the displays datasheet. Most cheap displays mostly simply emulate a mouse.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              E 1 Reply Last reply
              0
              • raven-worxR raven-worx

                @elliottal
                as i already stated in my first post.
                make sure that it actually sends touch events.
                Read the displays datasheet. Most cheap displays mostly simply emulate a mouse.

                E Offline
                E Offline
                elliottal
                wrote on last edited by
                #7

                @raven-worx
                I already did that. In my first post I said that I ran ts_calibrate and ts_test which is a part of the tslib library to verify the touch screen is working. Maybe I'm not understanding you correctly but I figure that would be enough to know that the touch screen is sending touch events. It does just emulate a mouse since it is labeled as HID-MOUSE. I figured that since I know the touch screen is working and does send touch events that I could run the code that I last sent to at least see that the touch events are being passed to QT.

                1 Reply Last reply
                0

                • Login

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