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

查看:184
本文介绍了您如何重新校准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-平台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);
}

mainwindow.h

mainwindow.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天全站免登陆