I'm trying to run Qt applications on a Raspberry Pi 3 that have a Waveshare LCD Touchscreen (with resistive touch) as IO. The Qt version I'm using is 5.12 and the Raspberry Pi's Operating System is Raspbian Stretch. I'm using tslib as the input driver, cause evdev is not working properly with my touch.

tslib solved a problem I have with evdev, but created some new problems:

If I press the widget and hold it down for some time, it generates one MousePress, wait some milliseconds, then generate two more MousePresses.

When I just click (press immediately followed by release) some widget, tslib generates two MousePresses and two MouseReleases instead of one each.

Here are the environment variables I have defined on /etc/environment:

Qt Code:
  1. QT_QPA_PLATFORM=xcb
  2. QT_QPA_FB_TSLIB=1
  3. QT_PLUGIN_PATH=/usr/local/qt5pi/plugins
  4. QT_QPA_PLATFORM_PLUGIN_PATH=/usr/local/qt5pi/plugins/platforms
  5. QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/touchscreen
  6. TSLIB_TSEVENTTYPE=INPUT
  7. TSLIB_FBDEVICE=/dev/fb0
  8. TSLIB_TSDEVICE=/dev/input/touchscreen
  9. TSLIB_CALIBFILE=/etc/pointercal
  10. TSLIB_CONFFILE=/etc/ts.conf
  11. TSLIB_PLUGINDIR=/usr/local/lib/ts
To copy to clipboard, switch view to plain text mode 

And here is the code I'm using to test tslib:

Qt Code:
  1. #include <QApplication>
  2. #include <QPushButton>
  3. #include <QDebug>
  4.  
  5. class Button : public QPushButton
  6. {
  7. Q_OBJECT
  8. public:
  9. protected:
  10. void mousePressEvent(QMouseEvent* event) override { QPushButton::mousePressEvent(event); qDebug() << "Pressed"; }
  11. void mouseReleaseEvent(QMouseEvent* event) override { QPushButton::mouseReleaseEvent(event); qDebug() << "Released"; }
  12. };
  13.  
  14. int main(int argc, char* argv[])
  15. {
  16. QApplication app(argc, argv);
  17.  
  18. Button button {"button"};
  19. button.setFixedSize({60, 30});
  20. button.show();
  21.  
  22. return app.exec();
  23. }
To copy to clipboard, switch view to plain text mode 
Running the code above and clicking (press immediately followed by release) the button, I get the following output:

Qt Code:
  1. Pressed
  2. Released
  3. Pressed
  4. Released
To copy to clipboard, switch view to plain text mode 

And when I press the button, hold it down, and then release, I get this:

Qt Code:
  1. Pressed
  2. Pressed
  3. Pressed
  4. Released
To copy to clipboard, switch view to plain text mode 

What could be wrong with my system? Is there any Qt environment variable I forgot to define? Do I need to disable evdev to use tslib?