跳到主要内容

Qt 使用指南

安装Qt5开发环境

安装C/C++编译环境

$ sudo apt-get update
$ sudo apt-get install build-essential

安装Qt5开发工具

$ sudo apt-get install qtbase5-gles-dev qtchooser qt5-qmake qtbase5-dev-tools

检测安装Qt版本。

$ qmake -v
QMake version 3.1
Using Qt version 5.15.13 in /usr/lib/riscv64-linux-gnu

安装Qt5 wayland插件

$ sudo apt-get install qtwayland5

配置Qt5后端显示服务

$ export QT_QPA_PLATFORM=wayland

编译并运行Qt5程序

下载qtbase-opensource-src-gles

$ apt-get source qtbase-opensource-src-gles
$ tree qtbase-opensource-src-gles-5.15.13+dfsg -L 1
qtbase-opensource-src-gles-5.15.13+dfsg
├── bin
├── config_help.txt
├── config.tests
├── configure
├── configure.bat
├── configure.json
├── configure.pri
├── debian
├── dist
├── doc
├── examples
├── include
├── INSTALL
├── lib
├── LICENSE.FDL
├── LICENSE.GPL2
├── LICENSE.GPL3
├── LICENSE.GPL3-EXCEPT
├── LICENSE.LGPL3
├── LICENSE.LGPLv3
├── LICENSE.QT-LICENSE-AGREEMENT
├── mkspecs
├── qmake
├── qtbase.pro
├── src
├── sync.profile
├── tests
└── util

编译qtbase-opensource-src-gles

安装依赖

$ sudo apt-get build-dep qtbase-opensource-src-gles

编译

$ dpkg-buildpackage -us -uc -nc -b -j4

编译examples

使用qmake生成Makefile

$ cd qtbase-opensource-src-gles-5.15.13+dfsg/examples/widgets/animation/animatedtiles
$ qmake

使用make生成可执行文件

$ make

运行examples

$ ./animatedtiles

qt