How to Build, Install and Setting Qt Application

From FriendlyELEC WiKi
Revision as of 09:16, 20 August 2018 by Tzs (Talk | contribs) (Display Rotation)

Jump to: navigation, search

查看中文

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 QtMultimedia(VPU) Capacitive Touch Screen Board Model
RK3399 Qt 5.10.0 eglfs_kms, eglfs, xcb, webgl, vnc Yes Yes Yes Multiple-point touch Multiple screen display NanoPC-T4
S5P4418 Qt 5.10.0 eglfs, xcb, vnc Yes Yes No Multiple-point touch Single screen NanoPi S2/NanoPi M2A/NanoPi Fire2/NanoPC T2/Smart4418
S5P6818 Qt 5.10.0 eglfs, xcb, vnc Yes Yes No Multiple-point touch Single screen NanoPi M3/NanoPi Fire3/NanoPC T3
Allwinner H3 Qt 4.8.6 LinuxFB No No No Single-point touch Single screen NanoPi-Duo/NanoPi-M1-Plus/NanoPi-M1/NanoPi-NEO-Air/NanoPi-NEO-Core/NanoPi-NEO
Allwinner H5 Qt 4.8.6 LinuxFB No No No Single-point touch Single screen NanoPi-K1-Plus/NanoPi-NEO-Core2/NanoPi-NEO-Plus2/NanoPi-NEO2
Amlogic S905 Qt 5.9.1 LinuxFB No No No Single-point touch Single screen NanoPi-K2

2 Install Cross Compiler for Qt

(Note: RK3399 FriendlyCore needs to use the PC operating system Ubuntu 18.04 64-bit, other platforms needs Ubuntu 16.04 64-bit system
Here is a list of cross compilers for various CPUs and ARM boards:

CPU and OS Qt Version System requirement Compiler & QtSDK
RK3399 FriendlyCore Qt 5.10.0 Ubuntu 18.04 64bit download link
RK3399 Lubuntu Qt 5.10.0 Ubuntu 16.04 64bit download link
S5P4418 FriendlyCore Qt 5.10.0 Ubuntu 16.04 64bit download link
S5P6818 FriendlyCore Qt 5.10.0 Ubuntu 16.04 64bit download link
Allwinner H3 FriendlyCore Qt 4.8.6 Ubuntu 16.04 64bit download link
Allwinner H5 FriendlyCore Qt 4.8.6 Ubuntu 16.04 64bit download link
Amlogic S905 FriendlyCore Qt 5.9.1 Ubuntu 16.04 64bit download link

Install a cross compiler by running the following commands:

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


Or download it through the following webdisk link:http://dl.friendlyarm.com/qtsdkfriendlyelec

3 Cross Compile Qt Program

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

3.1 RK3399 FriendlyCore

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

3.2 RK3399 Lubuntu

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

3.3 S5P4418 FriendlyCore

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

3.4 S5P6818 FriendlyCore

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

3.5 Allwinner H3 FriendlyCore

export PATH=/opt/FriendlyARM/toolchain/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.6 Allwinner H5 FriendlyCore

export PATH=/opt/FriendlyARM/toolchain/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.7 Amlogic S905 FriendlyCore

export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/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 Cross-compiling Qt application in Docker

Cross-compiling Qt application in Docker:

5 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

6 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 RK3399 or S5P4418 or S5P6818 board:

git clone https://github.com/friendlyarm/QtE-Demo
mkdir build && cd build
qmake-qt5 ../QtE-Demo/QtE-Demo.pro
make
. setqt5env
./QtE-Demo

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

8 Display Rotation

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

CPU名称与OS Qt版本 屏幕旋转方法
RK3399 FriendlyCore Qt 5.10.0 kms方式运行时:

. setqt5env-kms
export QT_QPA_EGLFS_ROTATION=90
export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event0:rotate=90
./YourApp

可设置角度值为: 0, 90, 180, or 270

xcb方式运行时:
xrotate.sh -m CW
mv xorg.conf.new /etc/X11/xorg.conf
. setqt5env-xcb
startx ./YourApp -geometry 1280x800

备注: 上面的1280x800请更改为实际的屏幕分辨率,xrotate.sh的帮助信息请用xrotate.sh -h命令查看。

S5P4418 FriendlyCore Qt 5.10.0 export ROTATION=-90
. setqt5env
./YourApp

可设置角度值为: 0, 90, 180, -90
S5P6818 FriendlyCore Qt 5.10.0 export ROTATION=-90
. setqt5env
./YourApp

可设置角度值为: 0, 90, 180, -90
Allwinner H3 FriendlyCore Qt 4.8.6 . setqt4env
export QWS_DISPLAY='Transformed:Rot90'
./YourApp

可设置角度值为: 0, 90, 180, 270
Allwinner H5 FriendlyCore Qt 4.8.6 . setqt4env
export QWS_DISPLAY='Transformed:Rot90'
./YourApp

可设置角度值为: 0, 90, 180, 270
Amlogic S905 FriendlyCore Qt 5.9.1 . setqt5env
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:rotation=90
./YourApp

可设置角度值为: 0, 90, 180, 270

9 Common Issues

9.1 Compiler Error: ../QtE-Demo/main.cpp:18:21: fatal error: QtWidgets: No such file or directory

Solution: check your Makefile file generated by qmake. Qt5's path should point to sysroot i.e. rootfs-s5p4418 or rootfs-s5p6818. You need to check whether or not this directory exists under /opt. If it doesn't you need to reinstall your sdk.

9.2 Hide Console Cursor

Hide Cursor

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

Show Cursor

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

9.3 Hide/Show Mouse Cursor

When you run Qt5 EGLFS you can hide or show your mouse's cursor by setting the QT_QPA_EGLFS_HIDECURSOR environmental variable. When this variable is set to 1 the cursor will be hidden when it is set to 0 the cursor will show.

For example after setqt5env is executed run the following command:

export QT_QPA_EGLFS_HIDECURSOR=0

The cursor will show.

9.4 Extend Boot Logo's Display Time

Since Linux kernel by default sets output to a terminal a boot logo will soon be flushed. Sometimes users prefer their logo to stay for much longer time, This can be done by changing kernel configuration and recompiling a kernel

9.4.1 For Kernel 4.4

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

Disabling "Framebuffer Console support" allows a Logo to stay long enough until a Qt program runs.


9.4.2 For Kernel 3.4

Device Drivers --->
    Graphics support --->
         [*] Bootup logo --->
                  [ ]   Standard black and white Linux logo
                  [ ]   Standard 16-color Linux logo 
                  [ ]   Standard 224-color Linux logo 
                  [*]   Copy logo from previous FB
          Console display driver support  --->
                  [ ] Framebuffer Console support

Go to the "Device Drivers" -> "Graphics support" menu, enable the "Bootup logo" option, and select only the "Copy logo from previous FB" in the "Bootup logo" option.
Go back to the "Graphics support" menu, enter "Console display driver support" menu, disable "Framebuffer Console support" option.

10 Update Log

10.1 Dec-5-2017

  • Released English version

10.2 Dec-6-2017

  • Added Section 5

10.3 Jan-30-2018

  • Added Section 8