下载地址:http://pan.baidu.com/disk/home#from=share_pan_logo&path=%2FWizNote
名称为:tslib-1.4.tar.gz,解压到source/tslib1.4目录下
a. 配置
sudo apt-get install automake libtool
./autogen.sh
./configure CC=arm-cortex_a9-linux-gnueabi-gcc CXX=arm-cortex_a9-linux-gnueabi-g++ --prefix=/usr/local/qt-arm/tslib-1.4 --host=arm-cortex_a9-linux-gnueabi ac_cv_func_malloc_0_nonnull=yes --enable-debug=no
b. 编译和安装
make
sudo make install
完成后,tslib1.4将会安装到/usr/local/qt-arm/tslib-1.4。
c. 修改配置文件
接着需要将tslib-1.4/etc/ts.tsconf文件第二行中的“#module_raw_input”中的注释去掉,并删除前面的空格。
说明:之所以需要编译tslib-1.4,是因为在采用触摸屏的设备中,触摸屏性能的调试是个重要问题之一,因为电磁噪声的缘故,触摸屏容易存在点击不准确、有抖动等问题。tslib是一个开源的程序,能够为触摸屏驱动获得的采样提供诸如滤波、去抖、校准等功能,通常作为触摸屏驱动的适配层,为上层的应用提供了一个统一的接口。
下载地址:http://pan.baidu.com/disk/home#from=share_pan_logo&path=%2FWizNote
名称为:qt-everywhere-opensource-src-4.8.5.tar.gz, 解压到source/qt-4.8.5目录下
a. 指定交叉编译器
vi mkspecs/qws/linux-arm-g++/qmake.conf
b. 配置
export TSLIB_ROOT=/usr/local/qt-arm/tslib-1.4
export PKG_CONFIG_PATH=$TSLIB_ROOT/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=$TSLIB_ROOT/lib:$LD_LIBRARY_PATH
./configure -force-pkg-config --prefix=/usr/local/qt-arm/qt4.8.5 -opensource -release -shared -Declarative -fast -no-largefile -qt-sql-sqlite -qt3support -exceptions -xmlpatterns -no-glib -no-phonon -no-mmx -no-3dnow -no-sse -no-sse2 -svg -no-webkit -qt-zlib -qt-libtiff -qt-libpng -qt-libjpeg -make libs -make tools -nomake examples -nomake docs -nomake demo -no-nis -no-cups -iconv -no-dbus -xplatform qws/linux-arm-g++ -embedded arm -little-endian -qt-freetype -depths 16,24,32 -qt-gfx-linuxfb -qt-gfx-transformed -qt-gfx-multiscreen -no-gfx-vnc -no-gfx-qvfb -qt-kbd-linuxinput -no-kbd-qvfb -armfpa -no-mouse-qvfb -qt-mouse-linuxtp -qt-mouse-tslib -DQT_QLOCALE_USES_FCVT -DQT_NO_QWS_CURSOR -no-pch -I/usr/local/qt-arm/tslib-1.4/include -L/usr/local/qt-arm/tslib-1.4/lib -confirm-license
我在配置的时候碰到了如下错误:
The tslib functionality test failed!
You might need to modify the include and library search paths by editing
QMAKE_INCDIR and QMAKE_LIBDIR in
/home/jessen/source/qt//qt-everywhere-opensource-src-4.8.5/mkspecs/qws/linux-arm-g++.
提示找不到交叉编译器,但是我确信已经添加到环境变量中,无奈之下,我把a步骤中指定的交叉编译器统统改成了绝对路径,就此通过配置。
c. 修改源码
修改…/src/gui/embedded/qkbdlinuxinput_qws.cpp
#if 0
if (m_tty_fd >= 0) {
// save tty config for restore.
tcgetattr(m_tty_fd, &m_tty_attr);
struct ::termios termdata;
tcgetattr(m_tty_fd, &termdata);
// record the original mode so we can restore it again in the destructor.
::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode);
// setting this translation mode is even needed in INPUT mode to prevent
// the shell from also interpreting codes, if the process has a tty
// attached: e.g. Ctrl+C wouldn't copy, but kill the application.
::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
// set the tty layer to pass-through
termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
termdata.c_oflag = 0;
termdata.c_cflag = CREAD | CS8;
termdata.c_lflag = 0;
termdata.c_cc[VTIME]=0;
termdata.c_cc[VMIN]=1;
cfsetispeed(&termdata, 9600);
cfsetospeed(&termdata, 9600);
tcsetattr(m_tty_fd, TCSANOW, &termdata);
}
#endif
如果不修改的话,在嵌入式设备中使用环境变量QWS_KEYBOARD的时候,运行Qt程序,程序会被挂起,串口终端那边无法再输入任何东西。大多数人的解决办法就是使用QWS_USB_KEYBOARD,但是由于我使用的是不是USB键盘设备,所以这种方法对我没什么用。
d. 编译和安装
sudo make
sudo make install
完成后,qt将会被安装到/usr/local/qt-arm/qt4.8.5。
export PATH=$PATH:/usr/local/qt4.8.5-arm/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/qt4.8.5-arm/lib
#tslib...............
export TSDIR=/usr/local/qt-arm/tslib-1.4
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_PLUGINDIR=$TSDIR/lib/ts
export TSLIB_CONFFILE=$TSDIR/etc/ts.conf
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_TSEVENTTYPE=H3600
export PATH=$TSDIR/bin:$PATH
export LD_LIBRARY_PATH=$TSDIR/lib:$LD_LIBRARY_PATH
#qt4.8.5..............
export QTDIR=/usr/local/qt-arm/qt4.8.5
#export QWS_MOUSE_PROTO="Tslib:/dev/input/event1"
#export QWS_MOUSE_PROTO="Intellimouse:/dev/input/mice"
export QWS_MOUSE_PROTO="LinuxInput:/dev/input/event1 IntelliMouse:/dev/input/mice"
export QWS_SIZE=1024x600
export QWS_KEYBOARD="LinuxInput:/dev/input/event0"
#export QWS_DISPLAY="LinuxFb:mmWidth600:mmHeight480:0"
export QWS_DISPLAY="LinuxFB:/dev/fb0"
export QT_QWS_FONTDIR=$QTDIR/lib/fonts
export QT_PLUGIN_PATH=$QTDIR/plugins/
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
这里有个问题就是究竟event0是键盘还是event1是键盘,这个可以利用tslib-1.4/bin下的ts_tests来测试。
或者
cat /proc/bus/input/devices
hello.cpp
#include
#include
int main(int argc,char *argv[])
{
QApplication app(argc,argv);
QPushButton btn("hello world!");
btn.show();
return app.exec();
}
在PC上接着编译,
qmake -project
qmake hello.pro
然后弄到arm下运行
./hello -qws
如果一切顺利的话就可以看到显示啦。