• ARM Linux DIY(十三)Qt5 移植


    前言

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

    移植 Qt5

    buildroot 使能 Qt5,这里我们只开启核心功能 gui module --> widgets module
    在这里插入图片描述
    编译

    $ make O=DIY_V3S/ qt5base
    
    • 1

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

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

    重新编译 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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

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

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

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

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

    方式二:环境变量

    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
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述

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

    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.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    添加字库

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

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

    运行

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

    请添加图片描述

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

    至此,Qt5 移植 OK。

  • 相关阅读:
    Vue3 + Naive-ui Data Table 分页页码显示不全
    Java 蓝桥杯校赛 谁最长?
    【OpenSSL】Ubuntu 下编译OpenSSL
    年搜索量超 7 亿次背后:这款 APP 用火山引擎 DataTester 完成“数据驱动”
    红路灯识别
    0 基础 Java 自学之路(5)
    《docker基础篇:Docker常规安装简介》包括docker常规安装总体步骤、安装tomcat、安装mysql、安装redis、安装nginx
    Win11系统的显卡驱动安装的详细方法步骤
    Reflection 反射
    【vue3】匿名插槽,具名插槽,作用域插槽,动态插槽
  • 原文地址:https://blog.csdn.net/lyndon_li/article/details/132955337