你如何重新校准Qt应用程序的触摸事件?

时间:2014-02-13 15:46:06

标签: c++ linux qt touch arm

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

我遇到的问题是触摸事件未校准到屏幕。例如:

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

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

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

我的问题:

  1. 过去有没有与Qt合作的人遇到这样的事情?
  2. 任何知道Qt的人都知道是否有能力以编程方式重新校准? (我似乎无法在Qt网站上找到任何相关信息)

  3. 可能有帮助或可能没有帮助的其他信息:

    我的Qt环境是使用以下命令配置的:

      

    ./ 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的主页配置/构建版本:

      

    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/仓:在/ usr /本地/奇趣/ QT-4.8.5 / bin中:/家庭/麦克/斌:/ usr / lib中/ lightdm / lightdm:在/ usr / local / sbin中:在/ usr / local / bin目录:/ usr / sbin目录:在/ usr / bin中:/ sbin目录:/ bin中:在/ usr /游戏:/首页/麦克风/斌

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

      

    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

    该应用程序启动时使用:

      

    ./ 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

    #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

    #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
    

1 个答案:

答案 0 :(得分:10)

所以我发现使用eglfs平台插件时不需要通过tslib提供触摸支持。 eglfs内置了evdev输入处理程序,因此鼠标/键盘/触摸支持无需连接到正确的设备。

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

export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS="rotate=180" 

这可以正确地转换坐标。