这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 活动中心 » 板卡试用 » 【树莓派5】03树莓派5Qt安装及使用

共1条 1/1 1 跳转至

【树莓派5】03树莓派5Qt安装及使用

菜鸟
2025-06-10 00:11:29     打赏

树莓派5 Qt安装及使用

一,安装qt

# 换源,这样可以快点

sudo apt-get -o Dir::Etc::SourceList="http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse" update

# 更新一下软件包索引

sudo apt update

# 安装qt

sudo apt install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools

#  安装qtcreator

sudo apt-get install qtcreator

# 安装其他依赖

sudo apt-get install qtdeclarative5-dev

sudo apt-get install libgles2-mesa-dev

sudo apt-get install libqt5serialport5-dev


1749485266828.png


如图已安装完成,可以点击打开,树莓派性能还是很强的,可以直接运行qtcreator,在线编辑和调试。

二,Hello world测试

工程创建这里就不演示了。

测试代码:

#include "mainwindow.h"

#include "ui_mainwindow.h"

#include "QPushButton"

MainWindow::MainWindow(QWidget *parent)

    : QMainWindow(parent)

    , ui(new Ui::MainWindow)

{

    ui->setupUi(this);

    this->setGeometry(0,0,1000,600);

    QPushButton *btn ;

    btn = new QPushButton(this);

    btn->setText("hello world");

    btn->setGeometry(200,200,200,80);

}


MainWindow::~MainWindow()

{

    delete ui;

}

三,测试结果

bc81e4acd7d6189c06fa412f8cb614f.jpg

7b2f026f351594007bc9851dd838522.jpg



共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]