01、重点知识公布
| 【1】Qt | windows Qt6.5.3安装&安卓环境搭建&虚拟机调试和真机调试完美版(保姆级教程) | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | VS2022 配置Qt编译环境 | winows安装Qt5.14.2 | VS2017和Qt5配置成功指南 | | 第二章 Ubuntu22.04 Linux磁盘扩容/硬盘扩展教程 | | 第一章 VMware Workstation Pro虚拟机安装Ubuntu20.04详细图文教程(图文并茂成功版) |
演示
02、手机连上adb,要玩一下步骤一定要阅读【1】
上一节没有连上,这一节电脑开机就连上了,接收过程如下
【0】手机插上USB,选择传输文件模式,共享USB网络;
【1】先用360手机助手连上手机,然后关闭助手;
【2】此时在命令行连续输入adb devices 然后就连上了,你说奇怪不奇怪;
【3】查看电脑-设备管理器-显示如下:有这个可能才代表了adb真正连上了。
【4】打开虫洞手机助手也连上了。
补充一点,需要在这个目录创建这个文件,输入手机的ID
格式:0x
03、创建APP应用程序
以下这两个编译都是可以的
创建成功。
此时我们先去这个界面连上真机,如果没出现,刷新一下,或者重启Qt Creator等等。【这里我之前是用苹果手机分享热点给华为手机,华为手机才是真正的真机调试,关闭热点刷新成功】
05、功能实现
此次我们借助腾讯云AI助手,实现一个日历。
VSCode搜索就有。
点击编译
点击是,不影响编译。
06、头文件
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include<QLabel>
#include<QPushButton>
#include<QVBoxLayout>
#include<QHBoxLayout>
#include<QGridLayout>
#include <QDate>
#include <QCalendarWidget>
#include <QDebug>
QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
void updateDateLabel();
private slots:
void on_prevButton_clicked();
void on_nextButton_clicked();
void on_todayButton_clicked();
private:
QLabel *dateLabel;
QPushButton *prevButton;
QPushButton *nextButton;
QPushButton *todayButton;
QCalendarWidget *calendarWidget;
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
07、源文件
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
dateLabel = new QLabel(this);
prevButton = new QPushButton(tr("&<"), this);
nextButton = new QPushButton(tr("&>"), this);
todayButton = new QPushButton(tr("&Today"), this);
calendarWidget = new QCalendarWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(prevButton);
buttonLayout->addWidget(nextButton);
buttonLayout->addWidget(todayButton);
mainLayout->addLayout(buttonLayout);
mainLayout->addWidget(calendarWidget);
setLayout(mainLayout);
connect(prevButton, &QPushButton::clicked, this, &Widget::on_prevButton_clicked);
connect(nextButton, &QPushButton::clicked, this, &Widget::on_nextButton_clicked);
connect(todayButton, &QPushButton::clicked, this, &Widget::on_todayButton_clicked);
updateDateLabel();
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_prevButton_clicked()
{
QDate date = calendarWidget->selectedDate().addDays(-1);
calendarWidget->setSelectedDate(date);
updateDateLabel();
}
void Widget::on_nextButton_clicked()
{
QDate date = calendarWidget->selectedDate().addDays(1);
calendarWidget->setSelectedDate(date);
updateDateLabel();
}
void Widget::on_todayButton_clicked()
{
QDate date = QDate::currentDate();
calendarWidget->setSelectedDate(date);
updateDateLabel();
}
void Widget::updateDateLabel()
{
dateLabel->setText(calendarWidget->selectedDate().toString("yyyy-MM-dd"));
}
08、 .ui文件和main.c不变
09、此时在手机端跳出了界面
10、发布
【1】上面是debug调试模式,现在我们使用release编译一下。
【2】如果编译失败,需要做以下动作。
点击项目
国家代码是CN,其他的随意
保存在了这个位置
确认,输入密码
点击编译
点击是
编译成功
总结
1、想玩Qt安卓阅读【Qt | windows Qt6.5.3安装&安卓环境搭建&虚拟机调试和真机调试完美版(保姆级教程)】
2、如果adb没有显示以下内容,尝试我的所有方法,如果还不行,就在群里剑流。
QQ群:927618678
故我在
Qt历险记
一名技术分享师,分享方向:->Qt(C/C++、linux、STM32、MySql/Sqlite3、TCP/UDP),设计方面->Ai、PS、visio、AD、Protues。 【v合作:Family_S_Health】