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

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
 
(31 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[How to Build and Install Qt Application for FriendlyELEC Boards/zh|查看中文]]
+
[[How to Build, Install and Setting Qt Application/zh|查看中文]]
  
 
==Qt Versions==
 
==Qt Versions==
Line 10: Line 10:
 
   | OpenGL
 
   | OpenGL
 
   | QtWebEngine
 
   | QtWebEngine
 +
  | QtMultimedia(VPU)
 
   | Capacitive Touch
 
   | Capacitive Touch
   | ARM Board
+
   | Screen
 +
  | Board Model
 +
|-
 +
  | RK3328/RK3399/RK3568/RK3588
 +
  | Qt 5.10.0
 +
  | eglfs_kms, eglfs, xcb, webgl, vnc
 +
  | <b>Yes</b>
 +
  | <b>Yes</b>
 +
  | <b>Yes</b>
 +
  | <b>Multiple-point touch</b>
 +
  | <b>Multiple screen display</b>
 +
  | NanoPC-T4/NanoPC-T6/NanoPi-R6S/NanoPi-R6C/CM3588/NanoPi-R5S/NanoPi-R5C
 
|-
 
|-
 
   | S5P4418
 
   | S5P4418
   | Qt 5.9.1
+
   | Qt 5.10.0
   | EGLFS
+
   | eglfs, xcb, vnc
   | Yes
+
   | <b>Yes</b>
   | Yes
+
   | <b>Yes</b>
   | Multiple-point touch
+
   | No
 +
  | <b>Multiple-point touch</b>
 +
  | Single screen
 
   | NanoPi S2/NanoPi M2A/NanoPi Fire2/NanoPC T2/Smart4418
 
   | NanoPi S2/NanoPi M2A/NanoPi Fire2/NanoPC T2/Smart4418
 
|-
 
|-
 
   | S5P6818
 
   | S5P6818
   | Qt 5.9.1
+
   | Qt 5.10.0
   | EGLFS
+
   | eglfs, xcb, vnc
   | Yes
+
   | <b>Yes</b>
   | Yes
+
   | <b>Yes</b>
   | Multiple-point touch
+
   | No
 +
  | <b>Multiple-point touch</b>
 +
  | Single screen
 
   | NanoPi M3/NanoPi Fire3/NanoPC T3
 
   | NanoPi M3/NanoPi Fire3/NanoPC T3
 
|-
 
|-
Line 32: Line 48:
 
   | Qt 4.8.6
 
   | Qt 4.8.6
 
   | LinuxFB
 
   | LinuxFB
 +
  | No
 
   | No
 
   | No
 
   | No
 
   | No
 
   | Single-point touch
 
   | Single-point touch
 +
  | Single screen
 
   | NanoPi-Duo/NanoPi-M1-Plus/NanoPi-M1/NanoPi-NEO-Air/NanoPi-NEO-Core/NanoPi-NEO
 
   | NanoPi-Duo/NanoPi-M1-Plus/NanoPi-M1/NanoPi-NEO-Air/NanoPi-NEO-Core/NanoPi-NEO
 
|-
 
|-
Line 40: Line 58:
 
   | Qt 4.8.6
 
   | Qt 4.8.6
 
   | LinuxFB
 
   | LinuxFB
 +
  | No
 
   | No
 
   | No
 
   | No
 
   | No
 
   | Single-point touch
 
   | Single-point touch
   | NanoPi-M1-Plus2/NanoPi-NEO-Core2/NanoPi-NEO-Plus2/NanoPi-NEO2
+
  | Single screen
 +
   | NanoPi-K1-Plus/NanoPi-NEO-Core2/NanoPi-NEO-Plus2/NanoPi-NEO2
 
|-
 
|-
 
   | Amlogic S905
 
   | Amlogic S905
 
   | Qt 5.9.1
 
   | Qt 5.9.1
 
   | LinuxFB
 
   | LinuxFB
 +
  | No
 
   | No
 
   | No
 
   | No
 
   | No
 
   | Single-point touch
 
   | Single-point touch
 +
  | Single screen
 
   | NanoPi-K2
 
   | NanoPi-K2
 
|}
 
|}
  
 
==Install Cross Compiler for Qt==
 
==Install Cross Compiler for Qt==
(Note: we suggest users use a host PC running a 64-bit Ubuntu 16.04) <br />
+
(Note: RK3328/RK3399/RK3568/RK3588 FriendlyCore needs to use the PC operating system Ubuntu 18.04 64-bit, other platforms needs Ubuntu 16.04 64-bit system <br />
Here is a list of cross compilers for various CPUs and ARM boards:  
+
[https://dl.friendlyelec.com/QtSDK-FriendlyELEC Click this link to download the compressed file]. The operating system requirements for the PC are shown in the table below:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
   | CPU
+
   | CPU and OS
 
   | Qt Version
 
   | Qt Version
   | Compiler & QtSDK
+
   | System requirement
 
|-
 
|-
   | S5P4418
+
   | RK3328/RK3399/RK3568/RK3588 FriendlyCore
   | Qt 5.9.1
+
   | Qt 5.10.0
   | [http://112.124.9.243/qtsdk-friendlyelec/s5p4418/ download link]
+
   | <b>Ubuntu 18.04 64bit</b>
 
|-
 
|-
   | S5P6818
+
   | RK3399 Lubuntu
   | Qt 5.9.1
+
   | Qt 5.10.0
   | [http://112.124.9.243/qtsdk-friendlyelec/s5p6818/ download link]
+
   | Ubuntu 16.04 64bit
 +
|-
 +
  | S5P4418 FriendlyCore
 +
  | Qt 5.10.0
 +
  | Ubuntu 16.04 64bit
 
|-
 
|-
   | Allwinner H3
+
  | S5P6818 FriendlyCore 32bit
 +
  | Qt 5.10.0
 +
  | Ubuntu 16.04 64bit
 +
|-
 +
  | S5P6818 FriendlyCore 64bit
 +
  | Qt 5.10.0
 +
  | Ubuntu 16.04 64bit
 +
|-
 +
   | Allwinner H3 FriendlyCore
 
   | Qt 4.8.6
 
   | Qt 4.8.6
   | [http://112.124.9.243/qtsdk-friendlyelec/h3/ download link]
+
   | Ubuntu 16.04 64bit
 
|-
 
|-
   | Allwinner H5
+
   | Allwinner H5 FriendlyCore
 
   | Qt 4.8.6
 
   | Qt 4.8.6
   | [http://112.124.9.243/qtsdk-friendlyelec/h5/ download link]
+
   | Ubuntu 16.04 64bit
 
|-
 
|-
   | Amlogic S905
+
   | Amlogic S905 FriendlyCore
 
   | Qt 5.9.1
 
   | Qt 5.9.1
   | [http://112.124.9.243/qtsdk-friendlyelec/s905/ download link]
+
   | Ubuntu 16.04 64bit
 
|}
 
|}
  
 
Install a cross compiler by running the following commands:
 
Install a cross compiler by running the following commands:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
tar xzf qtsdk-friendlyelec-20210403.tgz
 +
cd CPUName
 
chmod 755 ./install.sh
 
chmod 755 ./install.sh
 
sudo ./install.sh
 
sudo ./install.sh
Line 94: Line 130:
 
We took QtE-Demo as an example to show how to compile a Qt program.
 
We took QtE-Demo as an example to show how to compile a Qt program.
  
===S5P4418 Platform===
+
===RK3328/RK3399/RK3568/RK3588 FriendlyCore===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/QtE-Demo
 
git clone https://github.com/friendlyarm/QtE-Demo
 
mkdir build && cd build
 
mkdir build && cd build
/usr/local/Trolltech/Qt-5.9.1-nexell32-x86tools/bin/qmake ../QtE-Demo/QtE-Demo.pro
+
/usr/local/Trolltech/Qt-5.10.0-rk64one-sdk/bin/qmake ../QtE-Demo/QtE-Demo.pro
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
===S5P6818 Platform===
+
 
 +
===RK3399 Lubuntu===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
cd /work/
 
git clone https://github.com/friendlyarm/QtE-Demo
 
git clone https://github.com/friendlyarm/QtE-Demo
 
mkdir build && cd build
 
mkdir build && cd build
//usr/local/Trolltech/Qt-5.9.1-nexell64-x86tools/bin/qmake ../QtE-Demo/QtE-Demo.pro
+
/usr/local/Trolltech/Qt-5.10.0-rk32xcb-sdk/bin/qmake ../QtE-Demo/QtE-Demo.pro
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
===Allwinner H3 Platform===
+
 
 +
===S5P4418 FriendlyCore===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
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/Qt-5.10.0-nexell32-sdk/bin/qmake ../QtE-Demo/QtE-Demo.pro
 +
make
 +
</syntaxhighlight>
 +
===S5P6818 FriendlyCore===
 +
<syntaxhighlight lang="bash">
 +
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
 +
</syntaxhighlight>
 +
===Allwinner H3 FriendlyCore===
 +
<syntaxhighlight lang="bash">
 +
export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin/:$PATH
 
git clone https://github.com/friendlyarm/QtE-Demo
 
git clone https://github.com/friendlyarm/QtE-Demo
 
mkdir build && cd build
 
mkdir build && cd build
Line 116: Line 169:
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
===Allwinner H5 Platform===
+
===Allwinner H5 FriendlyCore===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
export PATH=/opt/FriendlyARM/toolschain/a64-32bit-tootchain/bin/:$PATH
+
export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin/:$PATH
 
git clone https://github.com/friendlyarm/QtE-Demo
 
git clone https://github.com/friendlyarm/QtE-Demo
 
mkdir build && cd build
 
mkdir build && cd build
/usr/local/Trolltech/QtEmbedded-4.8.6-arm-a64/bin/qmake ../QtE-Demo/QtE-Demo-Qt4.pro
+
/usr/local/Trolltech/QtEmbedded-4.8.6-arm/bin/qmake ../QtE-Demo/QtE-Demo-Qt4.pro
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
===Amlogic S905 Platform===
+
===Amlogic S905 FriendlyCore===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
export PATH=/opt/FriendlyARM/toolschain/a64-32bit-tootchain/bin/:$PATH
+
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
 
git clone https://github.com/friendlyarm/QtE-Demo
 
git clone https://github.com/friendlyarm/QtE-Demo
 
mkdir build && cd build
 
mkdir build && cd build
Line 132: Line 185:
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
==Cross-compiling Qt application in Docker==
 +
Cross-compiling Qt application in Docker:  <br />
 +
* [http://github.com/friendlyarm/friendlyelec-ubuntu18-docker RK3328/RK3399/RK3568/RK3588 FriendlyCore]
 +
* [http://github.com/friendlyarm/friendlyelec-ubuntu16-docker RK3399 Lubuntu, S5P4418/S5P6818/H3/H5 FriendlyCore]
  
 
==Run Qt Application on ARM Board==
 
==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:
+
Before you run a Qt application on a board you need to setup the environment variables.<br>
 
+
<br>
For Qt5 run setqt5env:
+
The RK3399/RK3568/RK3588 platforms provide four script files for setting Qt environment variables, as follows:
 +
::{| class="wikitable"
 +
|-
 +
|File name||Usage
 +
|-
 +
|/usr/bin/setqt5env-kms||Setting Qt environment variables for using the kms plugin
 +
|-
 +
|/usr/bin/setqt5env-eglfs||Setting Qt environment variables for using the eglfs plugin
 +
|-
 +
|/usr/bin/setqt5env-xcb||Setting Qt environment variables for using the xcb plugin
 +
|-
 +
|/usr/bin/setqt5env-nogui||For no-gui Qt only
 +
|}
 +
The S5P4418/S5P6818 platforms provide three script files for setting Qt environment variables, as follows:
 +
::{| class="wikitable"
 +
|-
 +
|File name||Usage
 +
|-
 +
|/usr/bin/setqt5env-eglfs||Setting Qt environment variables for using the eglfs plugin
 +
|-
 +
|/usr/bin/setqt5env-xcb||Setting Qt environment variables for using the xcb plugin
 +
|-
 +
|/usr/bin/setqt5env-nogui||For no-gui Qt only
 +
|}
 +
For example, to set up the Qt app interface to be displayed with the KMS plug-in, you can use the following command:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
. /usr/bin/setqt5env
+
. /usr/bin/setqt5env-kms
 
</syntaxhighlight>
 
</syntaxhighlight>
  
For Qt4 run setqt4env:
+
For Qt4, use setqt4env:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
. /usr/bin/setqt4env
 
. /usr/bin/setqt4env
Line 153: Line 235:
  
 
==Compile Qt Program on ARM Board==
 
==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:
+
 
===S5P4418 Platoform===
+
===Using qmake===
 +
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:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/QtE-Demo
 
git clone https://github.com/friendlyarm/QtE-Demo
 
mkdir build && cd build
 
mkdir build && cd build
/usr/local/Trolltech/Qt-5.9.1-nexell32-armhftools/bin/qmake ../QtE-Demo/QtE-Demo.pro
+
qmake-qt5 ../QtE-Demo/QtE-Demo.pro
 
make
 
make
 
. setqt5env
 
. setqt5env
 
./QtE-Demo
 
./QtE-Demo
 
</syntaxhighlight>
 
</syntaxhighlight>
===S5P6818 Platform===
+
===Using cmake (minesweeper as example)===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
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
 
. setqt5env
./QtE-Demo
+
git clone https://github.com/phoemur/minesweeper
 +
cd minesweeper
 +
mkdir -p build
 +
cd build
 +
cmake -DCMAKE_PREFIX_PATH=$QTDIR ..
 +
make -j4
 +
export DISPLAY=:0.0
 +
./minesweeper
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
The UI of minesweeper is shown below:<br />
 +
[[File:friendlydesktop-minesweeper-qt5.png|frameless|500px]]<br />
  
 
==Auto-Run Qt Application on System Startup==
 
==Auto-Run Qt Application on System Startup==
Line 181: Line 269:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
If this is a Qt4 system you need to change "setqt5env" to "setqt4env".
 
If this is a Qt4 system you need to change "setqt5env" to "setqt4env".
 +
 +
==Install the Qt5.10 examples==
 +
The Qt5.10 samples package can be found in the following path of the network disk:
 +
<syntaxhighlight lang="bash">
 +
sources/qt5.10-XXXXXX-examples
 +
</syntaxhighlight>
 +
Use the following command to decompress on the development board:
 +
<syntaxhighlight lang="bash">
 +
sudo tar xvzf Qt-5.10.0-rk64one-examples.tgz -C /<br />
 +
</syntaxhighlight>
 +
Then run the example with the following command, such as the opengl example (the following command uses RK3399 FriendlyDesktop as the example):
 +
<syntaxhighlight lang="bash">
 +
export DISPLAY=:0.0
 +
/usr/local/Trolltech/Qt-5.10.0-rk64one/examples/opengl/hellowindow/hellowindow
 +
</syntaxhighlight>
  
 
==Display Rotation==
 
==Display Rotation==
Line 190: Line 293:
 
   | Display Rotation
 
   | Display Rotation
 
|-
 
|-
   | S5P4418
+
  | RK3328/RK3399/RK3568/RK3588 FriendlyCore
   | Qt 5.9.1
+
  | Qt 5.10.0
 +
  | '''for kms plugin:'''<br />
 +
. setqt5env-kms<br />
 +
export QT_QPA_EGLFS_ROTATION=90<br />
 +
export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event0:rotate=90<br />
 +
./YourApp<br />
 +
<br />
 +
Applicable rotation degrees: 0, 90, 180, or 270<br />
 +
<br />
 +
'''for xcb plugin:'''<br />
 +
xrotate.sh -m CW<br />
 +
mv xorg.conf.new /etc/X11/xorg.conf<br />
 +
. setqt5env-xcb<br />
 +
startx ./YourApp -geometry 1280x800<br />
 +
<br />Note: please change 1280x800 as screen resolution,xrotate.sh -h to get help<br />
 +
|-
 +
   | S5P4418 FriendlyCore
 +
   | Qt 5.10.0
 
   | export ROTATION=-90<br />. setqt5env<br />./YourApp<br /><br />Applicable rotation degrees: 0, 90, 180, -90
 
   | export ROTATION=-90<br />. setqt5env<br />./YourApp<br /><br />Applicable rotation degrees: 0, 90, 180, -90
 
|-
 
|-
   | S5P6818
+
   | S5P6818 FriendlyCore
   | Qt 5.9.1
+
   | Qt 5.10.0
 
   | export ROTATION=-90<br />. setqt5env<br />./YourApp<br /><br />Applicable rotation degrees: 0, 90, 180, -90
 
   | export ROTATION=-90<br />. setqt5env<br />./YourApp<br /><br />Applicable rotation degrees: 0, 90, 180, -90
 
|-
 
|-
   | Allwinner H3
+
   | Allwinner H3 FriendlyCore
 
   | Qt 4.8.6
 
   | Qt 4.8.6
 
   | . setqt4env<br />export QWS_DISPLAY='Transformed:Rot90'<br />./YourApp<br /><br />Applicable rotation degrees: 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 FriendlyCore
 
   | Qt 4.8.6
 
   | Qt 4.8.6
 
   | . setqt4env<br />export QWS_DISPLAY='Transformed:Rot90'<br />./YourApp<br /><br />Applicable rotation degrees: 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 FriendlyCore
 
   | Qt 5.9.1
 
   | Qt 5.9.1
 
   | . 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
 
|}
 
|}
 +
===X11 Screen Rotation (RK3399 only)===
 +
When your Qt program is running on an X11 system, such as on the RK3399 platform, running a Qt program using xcb's plugin, or running a Qt program under Lubuntu, you can use X11's screen rotation feature.
 +
Currently, only eDP screen rotation is supported:<br>
 +
To rotate the eDP screen display, use the command xrotate.sh to rotate it by 90/180/270 degrees.<br><br>
 +
Running the following command as root will rotate the clock 90 degrees and restart the lightdm service so that the settings take effect immediately:<br>
 +
<syntaxhighlight lang="bash">
 +
sudo xrotate.sh -m CW -r
 +
</syntaxhighlight>
 +
Run xrotate -h for a detailed description of the parameters of this command.<br/>
 +
In addition, this command does not support HDMI display rotation for the time being, users can edit /etc/X11/xorg.conf by themselves.<br/>
  
 
==Common Issues==
 
==Common Issues==
 
===Compiler Error: ../QtE-Demo/main.cpp:18:21: fatal error: QtWidgets: No such file or directory===
 
===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.
 
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.
 +
 +
===Running Qt program under FriendlyDesktop can't cancel full screen? ===
 +
Use --platform xcb as the argument:
 +
<syntaxhighlight lang="bash">
 +
./HelloQt --platform xcb
 +
</syntaxhighlight>
 +
How to center the window:
 +
<syntaxhighlight lang="c">
 +
#include "widget.h"
 +
#include <QApplication>
 +
#include <QDesktopWidget>
 +
 +
int main(int argc, char *argv[])
 +
{
 +
    QApplication a(argc, argv);
 +
    Widget w;
 +
    w.adjustSize();
 +
    w.move(QApplication::desktop()->screen()->rect().center() - w.rect().center());
 +
    w.show();
 +
 +
    return a.exec();
 +
}
 +
</syntaxhighlight>
  
 
===Hide Console Cursor===
 
===Hide Console Cursor===
Line 232: Line 385:
 
export QT_QPA_EGLFS_HIDECURSOR=0
 
export QT_QPA_EGLFS_HIDECURSOR=0
 
</syntaxhighlight>
 
</syntaxhighlight>
The cursor will show.
+
The cursor will show, If the cursor is still not displayed, try turning off the hardware cursor by creating a configuration file such as kms-config.json with the following contents:
 +
<syntaxhighlight lang="bash">
 +
{
 +
    "device": "/dev/dri/card0",
 +
    "hwcursor": false
 +
}
 +
</syntaxhighlight>
 +
Then specify this configuration file using the environment variable:
 +
<syntaxhighlight lang="bash">
 +
export QT_QPA_EGLFS_KMS_CONFIG=$PWD/kms-config.json
 +
</syntaxhighlight>
 +
Example:
 +
<syntaxhighlight lang="bash">
 +
#!/bin/bash
 +
. /usr/bin/setqt5env-kms
 +
export QT_QPA_EGLFS_HIDECURSOR=0
 +
cd /opt/Qt5_CinematicExperience
 +
export QT_QPA_EGLFS_KMS_CONFIG=$PWD/kms-config.json
 +
[ $(id -u) -eq 0 ] && echo 0 > /sys/class/graphics/fbcon/cursor_blink
 +
./Qt5_CinematicExperience -qws
 +
[ $(id -u) -eq 0 ] && echo 1 > /sys/class/graphics/fbcon/cursor_blink
 +
</syntaxhighlight>
  
 
===Extend Boot Logo's Display Time===
 
===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<br />
+
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:<br />
+
This can be done by changing kernel configuration and recompiling a kernel<br />
 +
==== For Kernel 4.4 ====
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
Device Drivers --->
 
Device Drivers --->
Line 244: Line 419:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Disabling "Framebuffer Console support" allows a Logo to stay long enough until a Qt program runs.<br />
 
Disabling "Framebuffer Console support" allows a Logo to stay long enough until a Qt program runs.<br />
 +
 +
 +
==== For Kernel 3.4 ====
 +
<syntaxhighlight lang="bash">
 +
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   
 +
</syntaxhighlight>
 +
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. <br />
 +
Go back to the "Graphics support" menu, enter "Console display driver support" menu,  disable "Framebuffer Console support" option.<br />
  
 
==Update Log==
 
==Update Log==

Latest revision as of 08:02, 18 January 2024

查看中文

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
RK3328/RK3399/RK3568/RK3588 Qt 5.10.0 eglfs_kms, eglfs, xcb, webgl, vnc Yes Yes Yes Multiple-point touch Multiple screen display NanoPC-T4/NanoPC-T6/NanoPi-R6S/NanoPi-R6C/CM3588/NanoPi-R5S/NanoPi-R5C
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: RK3328/RK3399/RK3568/RK3588 FriendlyCore needs to use the PC operating system Ubuntu 18.04 64-bit, other platforms needs Ubuntu 16.04 64-bit system
Click this link to download the compressed file. The operating system requirements for the PC are shown in the table below:

CPU and OS Qt Version System requirement
RK3328/RK3399/RK3568/RK3588 FriendlyCore Qt 5.10.0 Ubuntu 18.04 64bit
RK3399 Lubuntu Qt 5.10.0 Ubuntu 16.04 64bit
S5P4418 FriendlyCore Qt 5.10.0 Ubuntu 16.04 64bit
S5P6818 FriendlyCore 32bit Qt 5.10.0 Ubuntu 16.04 64bit
S5P6818 FriendlyCore 64bit Qt 5.10.0 Ubuntu 16.04 64bit
Allwinner H3 FriendlyCore Qt 4.8.6 Ubuntu 16.04 64bit
Allwinner H5 FriendlyCore Qt 4.8.6 Ubuntu 16.04 64bit
Amlogic S905 FriendlyCore Qt 5.9.1 Ubuntu 16.04 64bit

Install a cross compiler by running the following commands:

tar xzf qtsdk-friendlyelec-20210403.tgz
cd CPUName
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 RK3328/RK3399/RK3568/RK3588 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 environment variables.

The RK3399/RK3568/RK3588 platforms provide four script files for setting Qt environment variables, as follows:

File name Usage
/usr/bin/setqt5env-kms Setting Qt environment variables for using the kms plugin
/usr/bin/setqt5env-eglfs Setting Qt environment variables for using the eglfs plugin
/usr/bin/setqt5env-xcb Setting Qt environment variables for using the xcb plugin
/usr/bin/setqt5env-nogui For no-gui Qt only

The S5P4418/S5P6818 platforms provide three script files for setting Qt environment variables, as follows:

File name Usage
/usr/bin/setqt5env-eglfs Setting Qt environment variables for using the eglfs plugin
/usr/bin/setqt5env-xcb Setting Qt environment variables for using the xcb plugin
/usr/bin/setqt5env-nogui For no-gui Qt only

For example, to set up the Qt app interface to be displayed with the KMS plug-in, you can use the following command:

. /usr/bin/setqt5env-kms

For Qt4, use setqt4env:

. /usr/bin/setqt4env

Run QtE-Demo:

./QtE-Demo -qws

6 Compile Qt Program on ARM Board

6.1 Using qmake

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

6.2 Using cmake (minesweeper as example)

. setqt5env
git clone https://github.com/phoemur/minesweeper
cd minesweeper
mkdir -p build
cd build
cmake -DCMAKE_PREFIX_PATH=$QTDIR ..
make -j4
export DISPLAY=:0.0
./minesweeper

The UI of minesweeper is shown below:
Friendlydesktop-minesweeper-qt5.png

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 Install the Qt5.10 examples

The Qt5.10 samples package can be found in the following path of the network disk:

sources/qt5.10-XXXXXX-examples

Use the following command to decompress on the development board:

sudo tar xvzf Qt-5.10.0-rk64one-examples.tgz -C /<br />

Then run the example with the following command, such as the opengl example (the following command uses RK3399 FriendlyDesktop as the example):

export DISPLAY=:0.0
/usr/local/Trolltech/Qt-5.10.0-rk64one/examples/opengl/hellowindow/hellowindow

9 Display Rotation

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

CPU Qt Version Display Rotation
RK3328/RK3399/RK3568/RK3588 FriendlyCore Qt 5.10.0 for kms plugin:

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

Applicable rotation degrees: 0, 90, 180, or 270

for xcb plugin:
xrotate.sh -m CW
mv xorg.conf.new /etc/X11/xorg.conf
. setqt5env-xcb
startx ./YourApp -geometry 1280x800

Note: please change 1280x800 as screen resolution,xrotate.sh -h to get help

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

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

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

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

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

Applicable rotation degrees: 0, 90, 180, 270

9.1 X11 Screen Rotation (RK3399 only)

When your Qt program is running on an X11 system, such as on the RK3399 platform, running a Qt program using xcb's plugin, or running a Qt program under Lubuntu, you can use X11's screen rotation feature. Currently, only eDP screen rotation is supported:
To rotate the eDP screen display, use the command xrotate.sh to rotate it by 90/180/270 degrees.

Running the following command as root will rotate the clock 90 degrees and restart the lightdm service so that the settings take effect immediately:

sudo xrotate.sh -m CW -r

Run xrotate -h for a detailed description of the parameters of this command.
In addition, this command does not support HDMI display rotation for the time being, users can edit /etc/X11/xorg.conf by themselves.

10 Common Issues

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

10.2 Running Qt program under FriendlyDesktop can't cancel full screen?

Use --platform xcb as the argument:

./HelloQt --platform xcb

How to center the window:

#include "widget.h"
#include <QApplication>
#include <QDesktopWidget>
 
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.adjustSize();
    w.move(QApplication::desktop()->screen()->rect().center() - w.rect().center());
    w.show();
 
    return a.exec();
}

10.3 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

10.4 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, If the cursor is still not displayed, try turning off the hardware cursor by creating a configuration file such as kms-config.json with the following contents:

{
    "device": "/dev/dri/card0",
    "hwcursor": false
}

Then specify this configuration file using the environment variable:

export QT_QPA_EGLFS_KMS_CONFIG=$PWD/kms-config.json

Example:

#!/bin/bash
. /usr/bin/setqt5env-kms
export QT_QPA_EGLFS_HIDECURSOR=0
cd /opt/Qt5_CinematicExperience
export QT_QPA_EGLFS_KMS_CONFIG=$PWD/kms-config.json
[ $(id -u) -eq 0 ] && echo 0 > /sys/class/graphics/fbcon/cursor_blink
./Qt5_CinematicExperience -qws
[ $(id -u) -eq 0 ] && echo 1 > /sys/class/graphics/fbcon/cursor_blink

10.5 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

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


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

11 Update Log

11.1 Dec-5-2017

  • Released English version

11.2 Dec-6-2017

  • Added Section 5

11.3 Jan-30-2018

  • Added Section 8