设备usb触摸线断开之后,即使重连,在已经运行的qt程序中,触摸失效,并且系统已经生成了触摸设备节点。
解决方法:使用tslib;修改qt源码中的src/gui/embedded/qmousetslib_qws.cpp
在QWSTslibMouseHandlerPrivate::readMouseData()的开始处加入以下代码,
void QWSTslibMouseHandlerPrivate::readMouseData()
{
if(!qt_screen)
return;
/* Support usb touchscreen hotplug */
int version;
if (ioctl(ts_fd(dev), EVIOCGVERSION, &version) < 0) {
disconnect(mouseNotifier, 0, 0, 0);
delete mouseNotifier;
while (1) {
if(open()) {
mouseNotifier = new QSocketNotifier(ts_fd(dev), QSocketNotifier::Read, this);
connect(mouseNotifier, SIGNAL(activated(int)), this, SLOT(readMouseData()));
resume();
return;
}
system("echo waiting for tp ...");
system("sleep 1");
}
}
/* end */
...
}但是重新编译qt会失败,错误一:缺少ioctl()的头文件, #include <sys/ioctl.h>
错误二:EVIOCGVERSION未定义 ,#define EVIOCGVERSION _IOR('E', 0x01, int) /* 获取驱动的版本信息*/ ;
之后编译,替换掉的libQtGui.so.4.8.6
本文介绍了一种解决USB触摸屏在Qt程序运行中因热插拔导致触摸失效的方法。通过修改Qt源码中的qmousetslib_qws.cpp文件,并添加特定代码来支持USB触摸屏的热插拔功能。文中还提到了编译过程中可能遇到的错误及解决办法。
4231

被折叠的 条评论
为什么被折叠?



