ARM Linux DIY(十三)Qt5 移植

前言

板子带有屏幕,那当然要设计一下 GUI,对 Qt5 比较熟悉,那就移植它吧。

移植 Qt5

buildroot 使能 Qt5,这里我们只开启核心功能 gui module --> widgets module
ARM Linux DIY(十三)Qt5 移植_第1张图片
编译

$ make O=DIY_V3S/ qt5base

编译报错:找不到 “sybfront.h”头文件
原因是:qt 依赖一些库,而这些库是我之前编译的,之前的 toolchain 没有使能 c++,
所以要把依赖的库重新编译一下
查看 qt5base 的依赖

$ make O=DIY_V3S/ qt5base-show-depends
freetype host-perl host-pkgconf host-skeleton libglib2 skeleton toolchain zlib

重新编译 perl,就好了

调试

指定平台

拷贝一个之前编译好的 Qt 应用程序到板子,运行

root@v3s-diy:~/qt# ./lyj_test_0401 
qt.qpa.plugin: Could not find the Qt platform plugin "eglfs" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: linuxfb, minimal, offscreen, vnc.

Aborted

运行报错,提示找不到平台插件,其实我们是有的

root@v3s-diy:~/qt# ls /usr/lib/qt/plugins/platforms/
libqlinuxfb.so    libqminimal.so    libqoffscreen.so  libqvnc.so

只不过没有告诉 Qt 应用程序,或者说告诉 Qt 动态库,要使用哪个,
有两种方式告诉它
方式一:命令行参数

root@v3s-diy:~/qt# ./lyj_test_0401 -platform linuxfb

方式二:环境变量

root@v3s-diy:~# export QT_QPA_PLATFORM="linuxfb:tty=/dev/fb0"
root@v3s-diy:~# echo $QT_QPA_PLATFORM
linuxfb:tty=/dev/fb0
root@v3s-diy:~/qt# ./lyj_test_0401

运行后,可以显示图像了,但是文字不显示,并且命令行有报错

root@v3s-diy:~/qt# ./lyj_test_0401 
QFontDatabase: Cannot find font directory /usr/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory /usr/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory /usr/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory /usr/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
QFontDatabase: Cannot find font directory /usr/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.

添加字库

从报错信息可以看到,是缺少字库
从之前的板子中拷贝一份字库过来

# mkdir /usr/lib/fonts
# cp SourceHanSansCN-Regular.otf /usr/lib/fonts

运行

root@v3s-diy:~/qt# ./lyj_test_0401

程序运行正常,画面显示正常。

至此,Qt5 移植 OK。

你可能感兴趣的:(#,QT,嵌入式,#,ARM,arm开发,linux,qt)