How to install tslib and configure Qt to use it?
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:
Code:
QT_QPA_PLATFORM=xcb
QT_QPA_FB_TSLIB=1
QT_PLUGIN_PATH=/usr/local/qt5pi/plugins
QT_QPA_PLATFORM_PLUGIN_PATH=/usr/local/qt5pi/plugins/platforms
QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/touchscreen
TSLIB_TSEVENTTYPE=INPUT
TSLIB_FBDEVICE=/dev/fb0
TSLIB_TSDEVICE=/dev/input/touchscreen
TSLIB_CALIBFILE=/etc/pointercal
TSLIB_CONFFILE=/etc/ts.conf
TSLIB_PLUGINDIR=/usr/local/lib/ts
And here is the code I'm using to test tslib:
Code:
#include <QApplication>
#include <QPushButton>
#include <QDebug>
{
Q_OBJECT
public:
protected:
void mousePressEvent
(QMouseEvent* event
) override
{ QPushButton::mousePressEvent(event
); qDebug
() <<
"Pressed";
} void mouseReleaseEvent
(QMouseEvent* event
) override
{ QPushButton::mouseReleaseEvent(event
); qDebug
() <<
"Released";
} };
int main(int argc, char* argv[])
{
Button button {"button"};
button.setFixedSize({60, 30});
button.show();
return app.exec();
}
Running the code above and clicking (press immediately followed by release) the button, I get the following output:
Code:
Pressed
Released
Pressed
Released
And when I press the button, hold it down, and then release, I get this:
Code:
Pressed
Pressed
Pressed
Released
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?