6. QT5 User Guide
6.1 Install Qt Creator
The following example illustrates how to install Qt Creator on Ubuntu.
- Install the Build Essential package.
sudo apt-get install build-essential
- Install Qt Creator.
sudo apt-get install qtcreator
- Install QT5 related environment.
sudo apt-get install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools qtbase5-examples qt5-doc qtbase5-doc-html
The following applications are displayed after the installation is completed.
6.2 Compile Qt programs
- Click the Qt Creator icon to enter the application.
- Choose Tools > Options. In the pop-up window, click Qt Versions and click Add.
- Select qmake under /usr/bin.
- Click Kits, scroll down, set the Qt version to Qt5.15, and click OK.
- Click Examples, type "Cube" in the input field, and click Cube OpenGL ES 2.0 example.
- In the pop-up window, click Keep Project and Open or Copy Project and Open as needed.
- Click Configure Project to enter the project.
- Click the play icon to run the project.
The project is successfully run. The next step is cross-compilation.
- Set up the cross-compilation environment. For details, refer to "1.11.2. Install cross-compilation tools".
source <your toolchains directory>/environment-setup-armv8-2a-qcom-linux
- Go to the project's source directory and execute qmke to generate the Makefile.
qmake
- Run the
qmake
andmake
commands for compilation.
- Transfer the compilation artifact to RUBIK Pi 3:
6.3 Configure the runtime environment
Qt chooses a default Qt Platform Abstraction (QPA) plug-in based on the platform. Alternatively, set the QT_QPA_PLATFORM environment variable or -platform command line parameter to select another platform plug-in. Commonly used platform plug-ins include LinuxFB, Wayland, and EGLFS.
-
LinuxFB
LinuxFB is displayed through Linux Framebuffer Device (FBDEV) which does not support hardware rendering, possibly resulting in poor display performance.
-
Wayland
Wayland is a display service protocol that does not rely on a client-server architecture and is intended to replace the X Window System with Linux and other Unix-like operating systems. Weston is the implementation reference of the Wayland open-source display protocol.
-
EGLFS
EGLFS is a GUI system implemented by Qt which does not support multiple windows. EGLFS uses opengles/egl for GPU rendering and then sends signals directly to DRM for display.
EGLFS is the recommended plug-in for modern Embedded Linux devices that include a GPU.
Use Wayland on RUBIK Pi 3:
export XDG_RUNTIME_DIR=/dev/socket/weston
export WAYLAND_DISPLAY=wayland-1
export QT_QPA_PLATFORM='wayland'
cd /opt
./cube
6.4 PyQt5
RUBIK Pi 3 supports PyQt5. The following example shows an example of PyQt5 demo.
import sys
from PyQt5.QtWidgets import QApplication, QWidget
app = QApplication(sys.argv)
w = QWidget()
w.resize(550, 500)
w.move(600, 300)
w.setWindowTitle('RUBIK Pi 3 PyQt5 demo title')
w.show()
sys.exit(app.exec_())
Transfer pyqt5.py to RUBIK Pi 3. For example, use the ADB method.
adb push pyqt5.py /opt
Run the following commands on RUBIK Pi 3 to run the demo.
export XDG_RUNTIME_DIR=/dev/socket/weston
export WAYLAND_DISPLAY=wayland-1
export QT_QPA_PLATFORM='wayland'
cd /opt
python3 pyqt5.py
The execution result is as follows: