gpt4 book ai didi

c++ - Qt 嵌入式触摸屏 QMouseEvents 在收到 MouseButtonRelease 之前未收到

转载 作者:太空狗 更新时间:2023-10-29 12:34:55 26 4
gpt4 key购买 nike

我在带有触摸屏的小型 ARM 嵌入式 Linux 设备上使用 Qt 4.8.3。我用 tslib 配置了我的触摸屏并对其进行了校准,因此/etc/中有一个 pointercal 文件。我的触摸事件的位置工作得很好,但无论我在鼠标按下或鼠标释放事件之前获得鼠标移动的 QEvent 是什么。此外,在我将手指从触摸屏上移开之前,我不会收到任何与鼠标相关的事件。我需要正常的行为,我按下触摸屏并立即收到鼠标按下事件,然后是我的移动事件(如果有的话),然后是当我抬起手指时的鼠标释放事件。

So what I'm seeing from the point of view of events received when I pressed down and then release looks like:

50 SockAct <-- Received right at press down
<-- NO Other events received until press released
<-- Now release by lifting finger from screen
50 SockAct <-- Immediately received a 50 ( SockAct ) and the rest of the events below:
2 <-- 2 == mouse down
2 <-- 2 == mouse down
3 <-- 3 == mouse release / up
3 <-- 3 == mouse release / up
77 <-- 77 == redraw

我还尝试通过实现以下 qwsEventFilter 来查看 QWS 服务器事件,以查看进入我的 QApplication 的 QWS 事件:

/// For investigation mouse events
#include <QWSServer>
#include <QWSMouseHandler>
#include <QWSEvent>

bool GUIApp::qwsEventFilter(QWSEvent *e)
{

qDebug() << e->type;

if(e->type == QWSEvent::Mouse) {

QWSMouseHandler *curMouse = QWSServer::mouseHandler();
qDebug() << "mouse position is: " << curMouse->pos();

}

return false;

/*
QWSEvent::NoEvent 0 No event has occurred.
QWSEvent::Connected 1 An application has connected to the server.
QWSEvent::Mouse 2 A mouse button is pressed or released, or the mouse cursor is moved. See also Qt for Embedded Linux Pointer Handling.
*/

}

现在,当我启动我的应用程序时,我在触摸屏幕后看到了相同的行为——即打印了以下内容:

2 <-- Nothing is printed until I release my finger from the screen!
mouse position is: QPoint(89,312)
2
mouse position is: QPoint(89,312)

如您所见,只要我松开手指,我就会收到 2 个事件,大概是按下并松开。

我已经在 Linux 中的/dev/input/touchscreen 设备上运行了“evtest”,并且在按下屏幕时肯定会立即看到触碰事件。在我抬起手指之前,我不会收到鼠标释放事件,因此驱动程序的行为符合预期。当我按下时也没有“重复”触地事件 - 它只是一次按下的一个事件,但行为正确。

我不确定为什么会看到我的行为。 Qt 和输入设备之间一定存在转换问题。

此外,如果我在处理我的 MouseButtonRelease 接收事件时添加了 3 毫秒的小延迟,那么我会在应用程序的工作方式方面获得所需的行为,但在我释放新闻之前我仍然没有收到我的鼠标事件。我根本不需要添加延迟,我希望我的鼠标按下,然后是任何移动,最后依次是鼠标松开事件

有谁知道如何解决这个问题或者是什么原因造成的??非常感谢!

--

在我真正抬起手指之前,我看不到以下打印出来的内容:

...
MOVE TYPE: 5
"Mouse move (382,129)"
MOUSE BUTTON PRESS TYPE: 2
"Mouse Button Press (1)"
MOUSE BUTTON RELEASE TYPE: 3
"Mouse Button Release (1)"
....

这是我的 eventFilter,我在其中检查应用程序中接收到的事件:

////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Just for kicks print out the mouse position
if (event->type() == QEvent::MouseButtonPress)
{
qDebug() << "MOUSE BUTTON PRESS TYPE: " << event->type();
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
qDebug() << QString("Mouse Button Press (%1)").arg(mouseEvent->button());
}
if (event->type() == QEvent::MouseMove)
{
qDebug() << "MOVE TYPE: " << event->type();
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
qDebug() << QString("Mouse move (%1,%2)").arg(mouseEvent->globalX()).arg(mouseEvent->globalY());
}
if (event->type() == QEvent::MouseButtonRelease)
{
qDebug() << "MOUSE BUTTON RELEASE TYPE: " << event->type();
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
delay();
qDebug() << QString("Mouse Button Release (%1)").arg(mouseEvent->button());
//return true; // Gobble the event
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

这是我的延迟函数:

void Monitor::delay()
{
QTime dieTime = QTime::currentTime().addMSecs(3);
while( QTime::currentTime() < dieTime )
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}

最佳答案

已解决 - 我找到了这个线程:https://github.com/kergoth/tslib/issues/10这概述了同样的问题。这似乎是 Tslib 中使用 Atmel MXT Maxtouch 驱动程序的问题。注释掉 ts.conf 文件中的 Variance 模块解决了我的问题 - 我现在在触摸屏幕后立即获得鼠标按下事件。

关于c++ - Qt 嵌入式触摸屏 QMouseEvents 在收到 MouseButtonRelease 之前未收到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14287733/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com