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_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
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
To copy to clipboard, switch view to plain text mode
And here is the code I'm using to test tslib:
#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();
}
#include <QApplication>
#include <QPushButton>
#include <QDebug>
class Button : public QPushButton
{
Q_OBJECT
public:
using QPushButton::QPushButton;
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[])
{
QApplication app(argc, argv);
Button button {"button"};
button.setFixedSize({60, 30});
button.show();
return app.exec();
}
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:
Pressed
Released
Pressed
Released
Pressed
Released
Pressed
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:
Pressed
Pressed
Pressed
Released
Pressed
Pressed
Pressed
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?
Bookmarks