Difference between revisions of "How to Build, Install and Setting Qt Application"

From FriendlyARM WiKi
Jump to: navigation, search
(Compile Qt Program on ARM Board)
(Update Log)
Line 210: Line 210:
 
   | . setqt5env<br />export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:rotation=90<br />./YourApp<br /><br />Applicable rotation degrees: 0, 90, 180, 270
 
   | . setqt5env<br />export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:rotation=90<br />./YourApp<br /><br />Applicable rotation degrees: 0, 90, 180, 270
 
|}
 
|}
 +
 +
==Common Issues==
 +
===编译程序出现错误 ../QtE-Demo/main.cpp:18:21: fatal error: QtWidgets: No such file or directory===
 +
解决办法:检查一下qmake所生成的Makefile,正常情况Qt5的包含路径指向的是 sysroot 的地址即  rootfs-s5p4418或rootfs-s5p6818,你需要/opt目录下是否存在这个目录,不存在的话就重新安装一下sdk。
 +
 +
===如何隐藏控制台光标?===
 +
关闭光标
 +
<syntaxhighlight lang="bash">
 +
sudo echo 0 > /sys/class/graphics/fbcon/cursor_blink
 +
</syntaxhighlight>
 +
恢复光标
 +
<syntaxhighlight lang="bash">
 +
sudo echo 1 > /sys/class/graphics/fbcon/cursor_blink
 +
</syntaxhighlight>
 +
 +
===如何隐藏和显示鼠标光标? ===
 +
使用Qt5 EGLFS运行程序时,通过QT_QPA_EGLFS_HIDECURSOR环境变量来控制鼠标光标的显示与隐藏, 设置为1时会隐藏光标,设置为0时会显示光标。<br />
 +
<br />
 +
例如,在执行 setqt5env 脚本之后执行:
 +
<syntaxhighlight lang="bash">
 +
export QT_QPA_EGLFS_HIDECURSOR=0
 +
</syntaxhighlight>
 +
即可显示光标。
 +
 +
===如何延长开机logo的显示时间?===
 +
由于内核在启动时会将屏幕初始化为终端,从而导致开机logo图片在短暂显示后就被冲掉变成黑屏,这在量产时是不愿意看到的,<br />
 +
可通过重新配置并编译内核来解决这个问题:<br />
 +
<syntaxhighlight lang="bash">
 +
Device Drivers --->
 +
    Graphics support --->
 +
        Console display dirver support --->
 +
            < > Framebuffer Console support
 +
</syntaxhighlight>
 +
禁用Framebuffer Console support 即可保持Logo的显示,直至Qt应用的运行。<br />
  
 
==Update Log==
 
==Update Log==

Revision as of 06:23, 30 January 2018

查看中文

1 Qt Versions

Qt has various versions for various platforms. Each Qt version has its own features and here a list of versions:

CPU Qt Version Display Driver OpenGL QtWebEngine Capacitive Touch ARM Board
S5P4418 Qt 5.9.1 EGLFS Yes Yes Multiple-point touch NanoPi S2/NanoPi M2A/NanoPi Fire2/NanoPC T2/Smart4418
S5P6818 Qt 5.9.1 EGLFS Yes Yes Multiple-point touch NanoPi M3/NanoPi Fire3/NanoPC T3
Allwinner H3 Qt 4.8.6 LinuxFB No No Single-point touch NanoPi-Duo/NanoPi-M1-Plus/NanoPi-M1/NanoPi-NEO-Air/NanoPi-NEO-Core/NanoPi-NEO
Allwinner H5 Qt 4.8.6 LinuxFB No No Single-point touch NanoPi-M1-Plus2/NanoPi-NEO-Core2/NanoPi-NEO-Plus2/NanoPi-NEO2
Amlogic S905 Qt 5.9.1 LinuxFB No No Single-point touch NanoPi-K2

2 Install Cross Compiler for Qt

(Note: we suggest users use a host PC running a 64-bit Ubuntu 16.04)
Here is a list of cross compilers for various CPUs and ARM boards:

CPU Qt Version Compiler & QtSDK
S5P4418 Qt 5.9.1 download link
S5P6818 Qt 5.9.1 download link
Allwinner H3 Qt 4.8.6 download link
Allwinner H5 Qt 4.8.6 download link
Amlogic S905 Qt 5.9.1 download link

Install a cross compiler by running the following commands:

chmod 755 ./install.sh
sudo ./install.sh

3 Cross Compile Qt Program

We took QtE-Demo as an example to show how to compile a Qt program.

3.1 S5P4418 Platform

git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
/usr/local/Trolltech/Qt-5.9.1-nexell32/bin/qmake ../QtE-Demo/QtE-Demo.pro
make

3.2 S5P6818 Platform

git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
/usr/local/Trolltech/Qt-5.9.1-nexell64/bin/qmake ../QtE-Demo/QtE-Demo.pro
make

3.3 Allwinner H3 Platform

export PATH=/opt/FriendlyARM/toolschain/4.9.3/bin/:$PATH
git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
/usr/local/Trolltech/QtEmbedded-4.8.6-arm/bin/qmake ../QtE-Demo/QtE-Demo-Qt4.pro
make

3.4 Allwinner H5 Platform

export PATH=/opt/FriendlyARM/toolschain/a64-32bit-tootchain/bin/:$PATH
git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
/usr/local/Trolltech/QtEmbedded-4.8.6-arm-a64/bin/qmake ../QtE-Demo/QtE-Demo-Qt4.pro
make

3.5 Amlogic S905 Platform

export PATH=/opt/FriendlyARM/toolschain/a64-32bit-tootchain/bin/:$PATH
git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
/usr/local/Trolltech/QtEmbedded-5.9.1-arch64/bin/qmake ../QtE-Demo/QtE-Demo.pro
make

4 Run Qt Application on ARM Board

Before you run a Qt application on a board you need to setup the board's environment variables by running the following commands on that board:

For Qt5 run setqt5env:

. /usr/bin/setqt5env

For Qt4 run setqt4env:

. /usr/bin/setqt4env

Run QtE-Demo:

./QtE-Demo -qws

5 Compile Qt Program on ARM Board

We took QtE-Demo as an example to show how to compile a Qt program on an ARM board. Currently this only applies to a S5P4418 or S5P6818 board:

5.1 S5P4418 Platoform

git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
/usr/local/Trolltech/Qt-5.9.1-nexell32-armhftools/bin/qmake ../QtE-Demo/QtE-Demo.pro
make
. setqt5env
./QtE-Demo

5.2 S5P6818 Platform

git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
/usr/local/Trolltech/Qt-5.9.1-nexell64-aarch64tools/bin/qmake ../QtE-Demo/QtE-Demo.pro
make
. setqt5env
./QtE-Demo

6 Auto-Run Qt Application on System Startup

In our test our QtE-Demo application was under the /root directory. Make sure your "/etc/rc.local" file has the following contents:

. /usr/bin/setqt5env
/root/QtE-Demo -qws&

If this is a Qt4 system you need to change "setqt5env" to "setqt4env".

7 Display Rotation

Here is a list of methods you can use to rotate your display for various platforms:

CPU Qt Version Display Rotation
S5P4418 Qt 5.9.1 export ROTATION=-90
. setqt5env
./YourApp

Applicable rotation degrees: 0, 90, 180, -90
S5P6818 Qt 5.9.1 export ROTATION=-90
. setqt5env
./YourApp

Applicable rotation degrees: 0, 90, 180, -90
Allwinner H3 Qt 4.8.6 . setqt4env
export QWS_DISPLAY='Transformed:Rot90'
./YourApp

Applicable rotation degrees: 0, 90, 180, 270
Allwinner H5 Qt 4.8.6 . setqt4env
export QWS_DISPLAY='Transformed:Rot90'
./YourApp

Applicable rotation degrees: 0, 90, 180, 270
Amlogic S905 Qt 5.9.1 . setqt5env
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:rotation=90
./YourApp

Applicable rotation degrees: 0, 90, 180, 270

8 Common Issues

8.1 编译程序出现错误 ../QtE-Demo/main.cpp:18:21: fatal error: QtWidgets: No such file or directory

解决办法:检查一下qmake所生成的Makefile,正常情况Qt5的包含路径指向的是 sysroot 的地址即 rootfs-s5p4418或rootfs-s5p6818,你需要/opt目录下是否存在这个目录,不存在的话就重新安装一下sdk。

8.2 如何隐藏控制台光标?

关闭光标

sudo echo 0 > /sys/class/graphics/fbcon/cursor_blink

恢复光标

sudo echo 1 > /sys/class/graphics/fbcon/cursor_blink

8.3 如何隐藏和显示鼠标光标?

使用Qt5 EGLFS运行程序时,通过QT_QPA_EGLFS_HIDECURSOR环境变量来控制鼠标光标的显示与隐藏, 设置为1时会隐藏光标,设置为0时会显示光标。

例如,在执行 setqt5env 脚本之后执行:

export QT_QPA_EGLFS_HIDECURSOR=0

即可显示光标。

8.4 如何延长开机logo的显示时间?

由于内核在启动时会将屏幕初始化为终端,从而导致开机logo图片在短暂显示后就被冲掉变成黑屏,这在量产时是不愿意看到的,
可通过重新配置并编译内核来解决这个问题:

Device Drivers --->
    Graphics support --->
        Console display dirver support --->
            < > Framebuffer Console support

禁用Framebuffer Console support 即可保持Logo的显示,直至Qt应用的运行。

9 Update Log

9.1 Dec-5-2017

  • Released English version

9.2 Dec-6-2017

  • Added Section 5