• 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。

  • 相关阅读:
    抖音系|巨量算数接口signature分析及解密
    黑盒测试和白盒测试的概念和区别你知道吗?
    嵌入式Linux应用开发基础知识(五)——Makefile函数
    php redis分布式锁
    spring Controller参数
    Cloud
    Go连接Redis:快速入门
    mysql 怎么做定时备份 / mysql 备份 / sql文件导出
    20230915-DBeaver 23.2.0 版本提取mybatis注解版内容未开启
    都说了别用BeanUtils.copyProperties,这不翻车了吧
  • 原文地址:https://blog.csdn.net/lyndon_li/article/details/132955337