你如何重新校准 Qt 应用程序的触摸事件? [英] how do you recalibrate touch events for a Qt application?

查看:25
本文介绍了你如何重新校准 Qt 应用程序的触摸事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 Qt5.2 应用程序,它是为 TI AM335x EVM(基于 ARM 的处理器)构建的.它只有 1 个按钮,可以启用板上的一些 LED.

I have a simple Qt5.2 application it's built for the TI AM335x EVM (ARM based processor). It just has 1 button on it which enables some LEDs on the board.

我遇到的问题是触摸事件未针对屏幕进行校准.示例:

The problem I'm having is that the touch event is not calibrated to the screen. Example:

*************
*           *
*  []       *
*       X   *
*           *
*************

因此,如果 [] 是按钮所在的位置,则 X 是您必须触摸以激活它的位置.就好像它是颠倒的和向后的.我尝试过更大的应用程序(更多按钮),趋势如下.

So if the [] is where the button is, the X is where you have to touch to activate it. It's like it's upside down and backwards. I've tried with larger applications (more buttons) and the trend follows.

现在,当我使用 TI 提供的 Qt4.8 GUI 用户界面时,触摸按预期工作,因此由于某种原因,当我通过 5.2 代码编译时,似乎需要重新校准,但我不确定如何这样做.

Now when I use the Qt4.8 GUI user interface provided by TI, the touch works as expected, so for some reason when I compile by 5.2 code it seems like it needs to be recalibrated, but I'm not sure how to do that.

我的问题:

  1. 过去有没有使用 Qt 的人遇到过这样的事情?
  2. 任何了解 Qt 的人都知道是否有以编程方式重新校准的能力?(我似乎在 Qt 网站上找不到任何关于此的信息)

<小时>

可能有帮助也可能没有帮助的其他信息:


Additional information that may or may not be helpful:

我的 Qt 环境是用这个命令配置的:

My Qt environment was configured with this command:

./configure -prefix/usr/Qt5.2 -xplatform linux-am335x-g++ -no-sse -no-sse2 -no-glib -no-cups -no-largefile -no-accessibility -no-openssl -no-gtkstyle -opensource

./configure -prefix /usr/Qt5.2 -xplatform linux-am335x-g++ -no-sse -no-sse2 -no-glib -no-cups -no-largefile -no-accessibility -no-openssl -no-gtkstyle -opensource

接着是 makemake install.我的路径已更新为包含正确版本的 TI 工具链和 qmake 的家庭配置/构建版本:

Followed by a make and make install. My path is updated to include the correct version of the TI toolchain and the home configured/built version of qmake:

mike@mike-VirtualBox:/usr/Qt5.2/test_button$ echo $PATH
/usr/Qt5.2/bin:/home/mike/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin:/usr/local/Trolltech/Qt-4.8.5/bin:/home/mike/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/mike/bin

mike@mike-VirtualBox:/usr/Qt5.2/test_button$ echo $PATH
/usr/Qt5.2/bin: /home/mike/ti-sdk-am335x-evm-06.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin:/usr/local/Trolltech/Qt-4.8.5/bin:/home/mike/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/mike/bin

实际编译命令中使用的标志:

Flags used in the actual compile command:

arm-linux-gnueabihf-g++ -c -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -O2 -Wall -W -D_REENTRANT -fPIE-DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../mkspecs/linux-am335x-g++ -I.-一世.-I../include -I../include/QtWidgets -I../include/QtGui -I../include/QtCore -I.-o main.o main.cpp

arm-linux-gnueabihf-g++ -c -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../mkspecs/linux-am335x-g++ -I. -I. -I../include -I../include/QtWidgets -I../include/QtGui -I../include/QtCore -I. -o main.o main.cpp

应用程序通过以下方式启动:

The application is launched with:

./touch_keys -platform eglfs

./touch_keys -platform eglfs

应用:

main.cpp:

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    MainWindow mainWindow;
    mainWindow.showMaximized();
    return app.exec();
}

mainwindow.cpp

mainwindow.cpp

#include "mainwindow.h"
#include <QtCore/QCoreApplication>
#include <QDebug>
#include <QFile>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    // Create the button, make "this" the parent
    m_button = new QPushButton("Light LEDs", this);

    // set size and location of the button
    m_button->setGeometry(QRect(QPoint(100, 100),
                                 QSize(200, 50)));

    // Connect button signal to appropriate slot
    connect(m_button, SIGNAL(released()), this, SLOT(handleButton()));
}

void MainWindow::handleButton()
{
    char buf[10];
    // change the text
    m_button->setText("Boom");

    // resize button
    m_button->resize(100,100);
}

主窗口.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPushButton>

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit MainWindow(QWidget *parent = 0);
private slots:
    void handleButton();
private:
    QPushButton *m_button;
};

#endif // MAINWINDOW_H

推荐答案

所以我发现在使用 eglfs 平台插件时应该不需要通过 tslib 的触摸支持.eglfs 内置了 evdev 输入处理程序,因此鼠标/键盘/触摸支持无需其他任何东西即可连接到正确的设备.

So I found out that the touch support via tslib should not be required when using the eglfs platform plugin. eglfs has the evdev input handlers built-in so mouse/keyboard/touch support come without needing anything else to connect to the correct device.

这意味着 evdevtouch 无法识别 am335x 上的触摸屏,这应该在 5.2 中得到纠正,但显然仍然没有.修复"(解决方法)是通过导出 QPA 环境变量手动翻转屏幕:

This means that evdevtouch is failing to recognize the touch screen on am335x, this was supposed to be corrected in 5.2, but clearly still isn't. The "fix" (workaround) is to flip the screen manually by exporting an QPA environment variable:

export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS="rotate=180" 

这正确地转换了坐标.

这篇关于你如何重新校准 Qt 应用程序的触摸事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆