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

From FriendlyARM WiKi
Jump to: navigation, search
Line 92: Line 92:
 
==Cross Compile Qt Program==
 
==Cross Compile Qt Program==
  
下面以下载并编译一个 QtE-Demo 为例,分别说明在各个平台编译一个 Qt应用程序的步骤:
+
We took QtE-Demo as an example to show how to compile a Qt program.
  
===S5P4418平台的编译===
+
===S5P4418 Platform===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/QtE-Demo
 
git clone https://github.com/friendlyarm/QtE-Demo
Line 101: Line 101:
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
===S5P6818平台的编译===
+
===S5P6818 Platform===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/QtE-Demo
 
git clone https://github.com/friendlyarm/QtE-Demo
Line 108: Line 108:
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
===Allwinner H3平台的编译===
+
===Allwinner H3 Platform===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
export PATH=/opt/FriendlyARM/toolschain/4.9.3/bin/:$PATH
 
export PATH=/opt/FriendlyARM/toolschain/4.9.3/bin/:$PATH
Line 116: Line 116:
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
===Allwinner H5平台的编译===
+
===Allwinner H5 Platform===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
export PATH=/opt/FriendlyARM/toolschain/a64-32bit-tootchain/bin/:$PATH
 
export PATH=/opt/FriendlyARM/toolschain/a64-32bit-tootchain/bin/:$PATH
Line 124: Line 124:
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
===Amlogic S905平台的编译===
+
===Amlogic S905 Platform===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
export PATH=/opt/FriendlyARM/toolschain/a64-32bit-tootchain/bin/:$PATH
 
export PATH=/opt/FriendlyARM/toolschain/a64-32bit-tootchain/bin/:$PATH
Line 133: Line 133:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==在开发板上运行Qt程序==
+
==Run Qt Application on ARM Board==
  
运行Qt程序之前,需要先设置环境变量,在开发板上执行以下命令即可:
+
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:
  
Qt5,使用 setqt5env:
+
For Qt5 run setqt5env:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
. /usr/bin/setqt5env
 
. /usr/bin/setqt5env
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Qt4,使用 setqt4env:
+
For Qt4 run setqt4env:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
. /usr/bin/setqt4env
 
. /usr/bin/setqt4env
 
</syntaxhighlight>
 
</syntaxhighlight>
  
例如运行上一章节编译的QtE-Demo:
+
Run QtE-Demo:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
./QtE-Demo -qws
 
./QtE-Demo -qws
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==开机自动运行Qt程序==
+
==Auto-Run Qt Application on System Startup==
  
以运行上一章节中的 QtE-Demo 程序为例,假设它放在 /root 目录,则你可以编辑 /etc/rc.local 文件,确否有以下内容:
+
In our test our QtE-Demo application was under the /root directory. Make sure your "/etc/rc.local" file has the following contents:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
. /usr/bin/setqt5env
 
. /usr/bin/setqt5env
 
/root/QtE-Demo -qws&
 
/root/QtE-Demo -qws&
 
</syntaxhighlight>
 
</syntaxhighlight>
如果是 Qt4,请将setqt5env改为setqt4env。
+
If this is a Qt4 system you need to change "setqt5env" to "setqt4env".
  
==屏幕旋转==
+
==Display Rotation==
根据你所用开发板的CPU型号,点击下表中的链接,下载链接内的所有文件到本地:  
+
Here is a list of methods you can use to rotate your display for various platforms:  
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
   | CPU名称
+
   | CPU
   | Qt版本
+
   | Qt Version
   | 屏幕旋转方法
+
   | Display Rotation
 
|-
 
|-
 
   | S5P4418
 
   | S5P4418
 
   | Qt 5.9.1
 
   | Qt 5.9.1
   | export ROTATION=-90<br />. setqt5env<br />./YourApp<br /><br />可设置角度值为: 0, 90, 180, -90
+
   | export ROTATION=-90<br />. setqt5env<br />./YourApp<br /><br />Applicable rotation degrees: 0, 90, 180, -90
 
|-
 
|-
 
   | S5P6818
 
   | S5P6818
 
   | Qt 5.9.1
 
   | Qt 5.9.1
   | export ROTATION=-90<br />. setqt5env<br />./YourApp<br /><br />可设置角度值为: 0, 90, 180, -90
+
   | export ROTATION=-90<br />. setqt5env<br />./YourApp<br /><br />Applicable rotation degrees: 0, 90, 180, -90
 
|-
 
|-
 
   | Allwinner H3
 
   | Allwinner H3
 
   | Qt 4.8.6
 
   | Qt 4.8.6
   | . setqt4env<br />export QWS_DISPLAY='Transformed:Rot90'<br />./YourApp<br /><br />可设置角度值为: 0, 90, 180, 270
+
   | . setqt4env<br />export QWS_DISPLAY='Transformed:Rot90'<br />./YourApp<br /><br />Applicable rotation degrees: 0, 90, 180, 270
 
|-
 
|-
 
   | Allwinner H5
 
   | Allwinner H5
 
   | Qt 4.8.6
 
   | Qt 4.8.6
   | . setqt4env<br />export QWS_DISPLAY='Transformed:Rot90'<br />./YourApp<br /><br />可设置角度值为: 0, 90, 180, 270
+
   | . setqt4env<br />export QWS_DISPLAY='Transformed:Rot90'<br />./YourApp<br /><br />Applicable rotation degrees: 0, 90, 180, 270
 
|-
 
|-
 
   | Amlogic S905
 
   | Amlogic S905
 
   | Qt 5.9.1
 
   | Qt 5.9.1
   | . setqt5env<br />export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:rotation=90<br />./YourApp<br /><br />可设置角度值为: 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
 
|}
 
|}

Revision as of 07:42, 5 December 2017

查看中文

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

6 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