问题描述
我有一个简单的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.
我的问题:
- 过去与Qt合作的人有遇到过这种情况吗?
- 任何了解Qt的人都知道是否可以通过程序进行重新校准吗? (我似乎在Qt网站上找不到关于此的任何信息)
可能有用或可能无效的其他信息:
Additional information that may or may not be helpful:
我的Qt环境是使用以下命令配置的:
My Qt environment was configured with this command:
后跟make
和make 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
:
实际编译命令中使用的标记:
Flags used in the actual compile command:
应用程序通过以下方式启动:
The application is launched with:
应用程序:
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应用程序的触摸事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!