up new code

This commit is contained in:
JasonYANG170 2024-05-09 11:00:07 +08:00
commit a9606ff58a
32 changed files with 2384 additions and 0 deletions

0
.env Normal file
View File

41
IOT.pro Normal file
View File

@ -0,0 +1,41 @@
QT += core gui
QT += mqtt
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
dialog.cpp \
dialog2.cpp \
form.cpp \
main.cpp \
mainwindow.cpp
HEADERS += \
dialog.h \
dialog2.h \
form.h \
mainwindow.h
FORMS += \
dialog.ui \
dialog2.ui \
form.ui \
mainwindow.ui
TRANSLATIONS += \
IOT_zh_CN.ts
CONFIG += lrelease
CONFIG += embed_translations
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
DISTFILES += \
.env

271
IOT.pro.user Normal file
View File

@ -0,0 +1,271 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 13.0.1, 2024-05-09T10:45:35. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{5913d737-a7b3-40d5-81b3-ef43144c2778}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">8</value>
<value type="bool" key="ClangTools.PreferConfigFile">false</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
<valuemap type="QVariantMap" key="CppEditor.QuickFix">
<value type="bool" key="UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.8.0 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.8.0 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.dev.win64_mingw_kit</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\qw200\Documents\C or C++ for YANG\build-IOT-Desktop_Qt_6_6_0_MinGW_64_bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/qw200/Documents/C or C++ for YANG/build-IOT-Desktop_Qt_6_6_0_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:\C++-QT\build-IOT-Desktop_Qt_6_6_0_MinGW_64_bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">E:/C++-QT/build-IOT-Desktop_Qt_6_6_0_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="int" key="QtQuickCompiler">0</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\qw200\Documents\C or C++ for YANG\build-IOT-Desktop_Qt_6_6_0_MinGW_64_bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/qw200/Documents/C or C++ for YANG/build-IOT-Desktop_Qt_6_6_0_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="int" key="QtQuickCompiler">0</value>
<value type="int" key="SeparateDebugInfo">0</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="QList&lt;int&gt;" key="Analyzer.Valgrind.VisibleErrorKinds"></value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph &quot;dwarf,4096&quot; -F 250</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">IOT2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:E:/C++-QT/IOT/IOT.pro</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">E:/C++-QT/IOT/IOT.pro</value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">true</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

3
IOT_zh_CN.ts Normal file
View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN"></TS>

1
README.md Normal file
View File

@ -0,0 +1 @@
## HI

269
dialog.cpp Normal file
View File

@ -0,0 +1,269 @@
#include "dialog.h"
#include "ui_dialog.h"
#include <QtMqtt/QtMqtt>
#include <QMessageBox>
QStringList parts;
QByteArray byteArray;
QString formattedVersion;
QString newves;
QString ID;
QString remainderx;
Dialog::Dialog(const QString& text, QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog),
client(new QMqttClient(this))
{
ui->setupUi(this);
setWindowTitle("设备管理");
ID=text;
ui->label_6->setText("设备ID"+text);
trimmedText = text.mid(2); // 从索引2即"fp"之后)开始截取文本
client->setHostname("url");
client->setPort(123);
client->setClientId("clientid");
client->connectToHost();
QObject::connect(client, &QMqttClient::connected, [this]() {
qDebug() << "Connected to MQTT broker!";
// 订阅主题
QMqttTopicFilter filter("Flowerpot");
client->subscribe(filter);
});
QObject::connect(client, &QMqttClient::messageReceived, [this](const QByteArray& message, const QMqttTopicName& topic) {
QString messageContent = message;
QString desiredPrefix = "#ID" + trimmedText;
formattedVersion ="";
if (messageContent.startsWith(desiredPrefix)) {
ui->label_7->setText("设备状态:在线");
QString messageString = QString::fromUtf8(message);
qDebug() << "Received message:" << message << "from topic:" << topic.name();
parts = messageString.split('#');
for (const QString& part : parts) {
qDebug() << "Split part:" << part;
}
QString firmwareVersion = parts[8];
int versionNumber = firmwareVersion.toInt(); // 将字符串转换为整数
int x = versionNumber / 100; // 获取百位数
int y = (versionNumber / 10) % 10; // 获取十位数
int z = versionNumber % 10; // 获取个位数
formattedVersion = QString("V%1.%2.%3").arg(x).arg(y).arg(z); // 创建格式化后的版本号字符串
ui->label_8->setText("固件版本:"+formattedVersion);
ui->label_3->setText(parts[2]+"%");
ui->label_4->setText(parts[4]+"%");
ui->label_5->setText(parts[3]+"%");
if(parts[6]=="1"){
ui->pushButton->setStyleSheet("background-color: red;");
}else{
ui->pushButton->setStyleSheet("background-color: white;");
}
if(parts[7]=="1"){
ui->pushButton_2->setStyleSheet("background-color: red;");
}else{
ui->pushButton_2->setStyleSheet("background-color: white;");
}
if(parts[5]=="1"){
ui->pushButton_3->setStyleSheet("background-color: red;");
}else{
ui->pushButton_3->setStyleSheet("background-color: white;");
}
ui->checkBox->blockSignals(true);
if (parts[9] == "1") {
ui->checkBox->setCheckState(Qt::Checked); // 设置为选中状态
} else {
ui->checkBox->setCheckState(Qt::Unchecked); // 设置为未选中状态
}
ui->checkBox->blockSignals(false);
} else {
// 忽略其他的消息
}
});
//更新检查服务器
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QUrl url("updata url");
QNetworkRequest request(url);
// Set unsafe SSL configuration
QSslConfiguration config = request.sslConfiguration();
config.setPeerVerifyMode(QSslSocket::VerifyNone);
request.setSslConfiguration(config);
QNetworkReply *reply = manager->get(request);
// Connect to the finished signal
connect(reply, &QNetworkReply::finished, [=]() {
if (reply->error() == QNetworkReply::NoError) {
// Read the JSON data
QByteArray data = reply->readAll();
// Display the JSON data in a message box
QJsonDocument jsonDoc = QJsonDocument::fromJson(QString(data).toUtf8());
QJsonObject jsonObj = jsonDoc.object();
// 获取数据
QJsonObject jObj2 = jsonDoc["data"].toObject();
QString str = jObj2 ["content"].toString();
qDebug() << str;
newves = str.left(6); // 提取前6个字符组成newves
remainderx = str.mid(6); // 提取剩下的字符
remainderx.replace("#", "\n");
qDebug() << "update1111111";
qDebug() << newves;
qDebug() << formattedVersion;
if (newves != formattedVersion) {
// QMessageBox::warning(this, "Error", "已发布新版本\"" + info + "\"。\n点击\"设置\"下载最新版本。");
// ui->pushButton_4->setText("发现新版本");
ui->pushButton_6->setStyleSheet("background-color: red;");
ui->pushButton_6->setText("发现新版本!");
qDebug() << "update";
}
else {
// ui->pushButton_4->setText("暂无更新");
qDebug() << "no";
}
}
else {
// Display an error message
QMessageBox::warning(this, "Error", reply->errorString());
}
// Clean up
reply->deleteLater();
manager->deleteLater();
});
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::on_pushButton_clicked()
{
if (client->state() == QMqttClient::Connected) {
QMqttTopicName topic("Flowerpot");
if (parts[6]=="1") {
QString str = "#IDTO" + trimmedText+"&OFFHOT";
byteArray = str.toUtf8();
}else{
QString str = "#IDTO" + trimmedText+"&ONHOT";
byteArray = str.toUtf8();
}
client->publish(topic, byteArray, 0, false);
// 发送消息后做其他处理
} else {
QMessageBox::warning(this, "Error", "MQTT client is not connected!");
}
}
void Dialog::on_pushButton_2_clicked()
{
if (client->state() == QMqttClient::Connected) {
QMqttTopicName topic("Flowerpot");
if (parts[7]=="1") {
QString str = "#IDTO" + trimmedText+"&OFFLED";
byteArray = str.toUtf8();
}else{
QString str = "#IDTO" + trimmedText+"&ONLED";
byteArray = str.toUtf8();
}
client->publish(topic, byteArray, 0, false);
// 发送消息后做其他处理
} else {
QMessageBox::warning(this, "Error", "MQTT client is not connected!");
}
}
void Dialog::on_pushButton_3_clicked()
{
if (client->state() == QMqttClient::Connected) {
QMqttTopicName topic("Flowerpot");
if (parts[5]=="1") {
QString str = "#IDTO" + trimmedText+"&OFFPUMP";
byteArray = str.toUtf8();
}else{
QString str = "#IDTO" + trimmedText+"&ONPUMP";
byteArray = str.toUtf8();
}
client->publish(topic, byteArray, 0, false);
// 发送消息后做其他处理
} else {
QMessageBox::warning(this, "Error", "MQTT client is not connected!");
}
}
void Dialog::on_pushButton_4_clicked()
{
// 实例化第二个 Dialog2 对象
Dialog2 dialog2;
// 显示第二个 Dialog2
dialog2.exec();
}
void Dialog::on_pushButton_5_clicked()
{
}
void Dialog::on_pushButton_6_clicked()
{
form* formDialog = new form(ID, formattedVersion,newves,remainderx,this); // 使用其他名称替换 'form'
formDialog->show();
}
void Dialog::on_checkBox_stateChanged(int arg1)
{
if (arg1 == Qt::Checked) {
qDebug() << "复选框被选中";
// 根据选中状态执行特定操作
if (client->state() == QMqttClient::Connected) {
QMqttTopicName topic("Flowerpot");
QString str = "#IDTO" + trimmedText+"&ONAUTO";
byteArray = str.toUtf8();
client->publish(topic, byteArray, 0, false);
// 发送消息后做其他处理
} else {
QMessageBox::warning(this, "Error", "MQTT client is not connected!");
}
} else if (arg1 == Qt::Unchecked) {
qDebug() << "复选框未被选中";
// 根据未选中状态执行特定操作
if (client->state() == QMqttClient::Connected) {
QMqttTopicName topic("Flowerpot");
QString str = "#IDTO" + trimmedText+"&OFFAUTO";
byteArray = str.toUtf8();
client->publish(topic, byteArray, 0, false);
// 发送消息后做其他处理
} else {
QMessageBox::warning(this, "Error", "MQTT client is not connected!");
}
}
}
void Dialog::closeEvent(QCloseEvent *event)
{
// 断开 MQTT 连接
client->disconnectFromHost();
// 调用父类的关闭事件处理函数
QDialog::closeEvent(event);
}

44
dialog.h Normal file
View File

@ -0,0 +1,44 @@
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include "form.h" // 添加对 form.h 的引用
#include "ui_form.h"
#include <QMqttClient>
#include <QMqttTopicName>
#include "dialog2.h"
#include "ui_dialog2.h"
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(const QString& text, QWidget *parent = nullptr);
~Dialog();
protected:
void closeEvent(QCloseEvent *event) override;
private slots:
void on_pushButton_5_clicked();
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_3_clicked();
void on_pushButton_4_clicked();
void on_pushButton_6_clicked();
void on_checkBox_stateChanged(int arg1);
private:
Ui::Dialog *ui;
QMqttClient* client;
QString trimmedText;
};
#endif // DIALOG_H

242
dialog.ui Normal file
View File

@ -0,0 +1,242 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>401</width>
<height>367</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>130</height>
</size>
</property>
<property name="title">
<string>智能植物培育设备</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>设备ID:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>设备状态:离线</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>固件版本:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>你的植物似乎很开心</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>环境温度</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>0.00%</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>土壤湿度</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>0.00%</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>环境湿度</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>0.00%</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>150</height>
</size>
</property>
<property name="title">
<string>控制台</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>AI自动控制</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>环境恒温</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>环境光照</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>浇水</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="pushButton_4">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>AI对话</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_5">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>AI生长预测</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_6">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>检查固件更新</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

75
dialog2.cpp Normal file
View File

@ -0,0 +1,75 @@
#include "dialog2.h"
#include "qnetworkaccessmanager.h"
#include "qnetworkreply.h"
#include "ui_dialog2.h"
Dialog2::Dialog2(QWidget *parent)
: QDialog(parent)
, ui(new Ui::Dialog2)
{
ui->setupUi(this);
setWindowTitle("AI Chat");
}
Dialog2::~Dialog2()
{
delete ui;
}
QString strall;
QString discuss;
QString ask;
QString answer;
void Dialog2::on_pushButton_clicked()
{
ui->textBrowser->setPlainText("正在等待ChatGPT回答您的问题请稍等......");
ask=ui->textEdit->toPlainText();
discuss=discuss+"Q:"+ask+"A:";
QString test2;"ESP8266控制电路数据上传"+ask;
qDebug() << "ESP8266控制电路数据上传:"+ui->textEdit->toPlainText();;
// if(ask.length()>880){
// QMessageBox::warning(this, "Error", "长度超出限制,当前共"+QString::number(ask.length())+"字节\n请删除部分字符使其控制在880字节以内。");
//}
int num=0;
QNetworkAccessManager manager;
// 创建POST请求
QUrl url("aiurl"); // 更换为你要访问的API地址
QNetworkRequest request(url);
QString accessToken = "token";
QByteArray authHeader = "Bearer " + accessToken.toUtf8();
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
request.setRawHeader("Authorization", authHeader);
// 准备POST数据
QByteArray postData;
postData.append("session_id=123&content=[{\"role\":\"system\",\"content\":\"You are Flowerpot AI, a large language model trained by YANG\\nCarefully heed the user's instructions.\\nRespond using Markdown.\\nCurrent Date: 2024/3/18 14:00:23\\n\"},{\"role\":\"user\",\"content\":\""+ask.toUtf8()+"\"}]&max_context_length=5&params={\"model\":\"gpt-3.5-turbo\",\"temperature\":1,\"max_tokens\":2048,\"presence_penalty\":0,\"frequency_penalty\":0,\"max_context_length\":5,\"voiceShortName\":\"zh-CN-XiaoxiaoNeural\",\"rate\":1,\"pitch\":1}"); // 根据API要求构建合适的POST参数
// 发送POST请求
QNetworkReply *reply = manager.post(request, postData);
// 等待请求完成
QEventLoop loop;
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
loop.exec();
QString str1="You:\n"+ask+"\n\n";
// 获取返回值
if(reply->error() == QNetworkReply::NoError) {
QString responsex = reply->readAll();
QString response= responsex.remove(responsex.length() - 6, 6);
QString str2="Chat Robot:\n"+response+"\n\n";
strall=strall+str1+str2;
ui->textBrowser->setPlainText(strall);
QString test1="AI数据应答"+response;
qDebug() << test1;
} else {
qDebug() << "Error:" << reply->errorString();
}
// 清理
reply->deleteLater();
}

25
dialog2.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef DIALOG2_H
#define DIALOG2_H
#include <QDialog>
namespace Ui {
class Dialog2;
}
class Dialog2 : public QDialog
{
Q_OBJECT
public:
explicit Dialog2(QWidget *parent = nullptr);
~Dialog2();
private slots:
void on_pushButton_clicked();
private:
Ui::Dialog2 *ui;
};
#endif // DIALOG2_H

65
dialog2.ui Normal file
View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog2</class>
<widget class="QDialog" name="Dialog2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>347</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Flower Chat&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="minimumSize">
<size>
<width>0</width>
<height>230</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTextEdit" name="textEdit">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>51</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>51</height>
</size>
</property>
<property name="text">
<string>发送</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

98
form.cpp Normal file
View File

@ -0,0 +1,98 @@
#include "form.h"
#include "ui_form.h"
#include <QMessageBox>
#include <QtMqtt/QtMqtt>
QString st;
QString upid;
form::form(const QString& id, const QString& ves, const QString& newves, const QString& log,QWidget *parent) :
QDialog(parent),
ui(new Ui::form),
client(new QMqttClient(this))
{
ui->setupUi(this);
setWindowTitle("更新检查");
st=id;
upid = id.mid(2);
//设备更新
if(id!=""){
client->setHostname("mqtt");
client->setPort(123);
client->setClientId("clientid");
client->connectToHost();
QObject::connect(client, &QMqttClient::connected, [this]() {
qDebug() << "Connected to MQTT broker!";
// 订阅主题
QMqttTopicFilter filter("Flowerpot");
client->subscribe(filter);
});
ui->label_6->setText("设备ID"+id);
ui->label_8->setText("固件版本:"+ves);
ui->label_3->setText(ves);
ui->label_5->setText(newves);
ui->textBrowser->setText(log);
if(ves==""){
ui->label_7->setText("设备状态:离线");
}else{
ui->label_7->setText("设备状态:在线");
}
}
//程序更新
else{
ui->label_6->setText("万物互联IOT设备PC控制软件更新");
if(newves!=""){
ui->label_7->setText("服务器状态:在线");
}else{
ui->label_7->setText("服务器状态:离线");
}
ui->label_8->setText("服务器最新版本:"+newves);
ui->label->setText("当前版本:"+ves);
ui->label_3->setText(ves);
ui->label_5->setText(newves);
ui->textBrowser->setText(log);
}
}
form::~form()
{
delete ui;
}
#include <QDesktopServices>
#include <QUrl>
void form::on_pushButton_clicked()
{
if(st!=""){
QMqttTopicName topic("Flowerpot");
QString str = "#IDTO"+upid+"&Updata";
QByteArray byteArray = str.toUtf8();
client->publish(topic, byteArray, 0, false);
}else{
QMessageBox::information(this, "密码提示", "即将打开链接密钥2xzk");
QUrl url("updataurl"); // 替换为您要打开的网页URL
if (QDesktopServices::openUrl(url)) {
} else {
// 处理无法打开链接的错误
}
}
}
void form::closeEvent(QCloseEvent *event)
{
if(st!=""){
// 断开 MQTT 连接
client->disconnectFromHost();
// 调用父类的关闭事件处理函数
QDialog::closeEvent(event);
qDebug() << "offfff";
}
}

29
form.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef FORM_H
#define FORM_H
#include <QMqttClient>
#include <QMqttTopicName>
#include <QDialog>
namespace Ui {
class form;
}
class form : public QDialog
{
Q_OBJECT
protected:
void closeEvent(QCloseEvent *event) override;
public:
explicit form(const QString& id, const QString& ves, const QString& newves, const QString& log,QWidget *parent = nullptr);
~form();
private slots:
void on_pushButton_clicked();
private:
Ui::form *ui;
QMqttClient* client;
};
#endif // FORM_H

163
form.ui Normal file
View File

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>form</class>
<widget class="QDialog" name="form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>428</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>130</height>
</size>
</property>
<property name="title">
<string>更新</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>设备ID:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>设备状态:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>固件版本:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>你的植物似乎很开心</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>当前版本</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>V1.0.0</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>最新版本</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>V1.0.0</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>更新日志</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>175</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&gt;注意事项:&lt;/p&gt;&lt;p align=&quot;justify&quot;&gt;1.更新过程中请勿断开设备电源。&lt;/p&gt;&lt;p align=&quot;justify&quot;&gt;2.更新过程中请勿退出程序。&lt;/p&gt;&lt;p align=&quot;justify&quot;&gt;3.更新完成后,设备会自动重启。&lt;/p&gt;&lt;p align=&quot;justify&quot;&gt;4.设备重启过程中请耐心等待。&lt;/p&gt;&lt;p align=&quot;justify&quot;&gt;5.再次检查更新提示&lt;/p&gt;&lt;p align=&quot;justify&quot;&gt;“已是最新版本”时表明更新成功&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>更新</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

3
lib/Qt6Mqtt.prl Normal file
View File

@ -0,0 +1,3 @@
QMAKE_PRL_TARGET = libQt6Mqtt.a
QMAKE_PRL_CONFIG = shared
QMAKE_PRL_VERSION = 6.8.0

View File

@ -0,0 +1,8 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# TODO: Ideally this should look for each Qt module separately, with each module's specific version,
# bypassing the Qt6 Config file, aka find_package(Qt6SpecificFoo) repated x times. But it's not
# critical.
find_package(Qt6 6.8.0
COMPONENTS Mqtt)

View File

@ -0,0 +1,48 @@
# Additional target information for Qt6Mqtt
if(NOT DEFINED QT_DEFAULT_IMPORT_CONFIGURATION)
set(QT_DEFAULT_IMPORT_CONFIGURATION RELEASE)
endif()
__qt_internal_promote_target_to_global_checked(Qt6::Mqtt)
get_target_property(_qt_imported_location Qt6::Mqtt IMPORTED_LOCATION_RELEASE)
get_target_property(_qt_imported_implib Qt6::Mqtt IMPORTED_IMPLIB_RELEASE)
get_target_property(_qt_imported_location_default Qt6::Mqtt IMPORTED_LOCATION_${QT_DEFAULT_IMPORT_CONFIGURATION})
get_target_property(_qt_imported_implib_default Qt6::Mqtt IMPORTED_IMPLIB_${QT_DEFAULT_IMPORT_CONFIGURATION})
# Import target "Qt6::Mqtt" for configuration "RelWithDebInfo"
set_property(TARGET Qt6::Mqtt APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
if(_qt_imported_location)
set_property(TARGET Qt6::Mqtt PROPERTY IMPORTED_LOCATION_RELWITHDEBINFO "${_qt_imported_location}")
endif()
if(_qt_imported_implib)
set_property(TARGET Qt6::Mqtt PROPERTY IMPORTED_IMPLIB_RELWITHDEBINFO "${_qt_imported_implib}")
endif()
# Import target "Qt6::Mqtt" for configuration "MinSizeRel"
set_property(TARGET Qt6::Mqtt APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL)
if(_qt_imported_location)
set_property(TARGET Qt6::Mqtt PROPERTY IMPORTED_LOCATION_MINSIZEREL "${_qt_imported_location}")
endif()
if(_qt_imported_implib)
set_property(TARGET Qt6::Mqtt PROPERTY IMPORTED_IMPLIB_MINSIZEREL "${_qt_imported_implib}")
endif()
# Default configuration
if(_qt_imported_location_default)
set_property(TARGET Qt6::Mqtt PROPERTY IMPORTED_LOCATION "${_qt_imported_location_default}")
endif()
if(_qt_imported_implib_default)
set_property(TARGET Qt6::Mqtt PROPERTY IMPORTED_IMPLIB "${_qt_imported_implib_default}")
endif()
__qt_internal_promote_target_to_global_checked(Qt6::MqttPrivate)
unset(_qt_imported_location)
unset(_qt_imported_location_default)
unset(_qt_imported_soname)
unset(_qt_imported_soname_default)
unset(_qt_imported_objects)
unset(_qt_imported_objects_default)
unset(_qt_imported_clr)
unset(_qt_imported_clr_default)
unset(_qt_imported_configs)

View File

@ -0,0 +1,177 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
####### Any changes to this file will be overwritten by the next CMake run ####
####### The input file was QtModuleConfig.cmake.in ########
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
macro(set_and_check _var _file)
set(${_var} "${_file}")
if(NOT EXISTS "${_file}")
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
endif()
endmacro()
macro(check_required_components _NAME)
foreach(comp ${${_NAME}_FIND_COMPONENTS})
if(NOT ${_NAME}_${comp}_FOUND)
if(${_NAME}_FIND_REQUIRED_${comp})
set(${_NAME}_FOUND FALSE)
endif()
endif()
endforeach()
endmacro()
####################################################################################
cmake_minimum_required(VERSION 3.16...3.21)
include(CMakeFindDependencyMacro)
get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_import_prefix "${_import_prefix}" REALPATH)
# Extra cmake code begin
# Extra cmake code end
# Find required dependencies, if any.
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/Qt6MqttDependencies.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttDependencies.cmake")
_qt_internal_suggest_dependency_debugging(Mqtt
__qt_Mqtt_pkg ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
endif()
# If *ConfigDependencies.cmake exists, the variable value will be defined there.
# Don't override it in that case.
if(NOT DEFINED "Qt6Mqtt_FOUND")
set("Qt6Mqtt_FOUND" TRUE)
endif()
if (NOT QT_NO_CREATE_TARGETS AND Qt6Mqtt_FOUND)
include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttAdditionalTargetInfo.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttExtraProperties.cmake"
OPTIONAL)
# DEPRECATED
# Provide old style variables for includes, compile definitions, etc.
# These variables are deprecated and only provided on a best-effort basis to facilitate porting.
# Consider using target_link_libraries(app PRIVATE Qt6Mqtt) instead.
set(Qt6Mqtt_LIBRARIES "Qt6::Mqtt")
get_target_property(_Qt6Mqtt_OWN_INCLUDE_DIRS
Qt6::Mqtt INTERFACE_INCLUDE_DIRECTORIES)
if(NOT _Qt6Mqtt_OWN_INCLUDE_DIRS)
set(_Qt6Mqtt_OWN_INCLUDE_DIRS "")
endif()
if(TARGET Qt6::MqttPrivate)
get_target_property(_Qt6Mqtt_OWN_PRIVATE_INCLUDE_DIRS
Qt6::MqttPrivate INTERFACE_INCLUDE_DIRECTORIES)
if(NOT _Qt6Mqtt_OWN_PRIVATE_INCLUDE_DIRS)
set(_Qt6Mqtt_OWN_PRIVATE_INCLUDE_DIRS "")
endif()
endif()
get_target_property(Qt6Mqtt_DEFINITIONS
Qt6::Mqtt INTERFACE_COMPILE_DEFINITIONS)
if(NOT Qt6Mqtt_DEFINITIONS)
set(Qt6Mqtt_DEFINITIONS "")
else()
list(TRANSFORM Qt6Mqtt_DEFINITIONS PREPEND "-D")
endif()
get_target_property(Qt6Mqtt_COMPILE_DEFINITIONS
Qt6::Mqtt INTERFACE_COMPILE_DEFINITIONS)
if(NOT Qt6Mqtt_COMPILE_DEFINITIONS)
set(Qt6Mqtt_COMPILE_DEFINITIONS "")
endif()
set(Qt6Mqtt_INCLUDE_DIRS
${_Qt6Mqtt_OWN_INCLUDE_DIRS})
set(Qt6Mqtt_PRIVATE_INCLUDE_DIRS
${_Qt6Mqtt_OWN_PRIVATE_INCLUDE_DIRS})
foreach(_module_dep ${_Qt6Mqtt_MODULE_DEPENDENCIES})
if(_module_dep MATCHES ".+Private$")
set(_private_suffix "Private")
else()
set(_private_suffix "")
endif()
list(APPEND Qt6Mqtt${_private_suffix}_INCLUDE_DIRS
${Qt6${_module_dep}_INCLUDE_DIRS})
list(APPEND Qt6Mqtt${_private_suffix}_PRIVATE_INCLUDE_DIRS
${Qt6${_module_dep}_PRIVATE_INCLUDE_DIRS})
if(_private_suffix)
list(APPEND Qt6Mqtt_PRIVATE_INCLUDE_DIRS
${Qt6${_module_dep}_PRIVATE_INCLUDE_DIRS})
endif()
list(APPEND Qt6Mqtt${_private_suffix}_DEFINITIONS
${Qt6${_module_dep}_DEFINITIONS})
list(APPEND Qt6Mqtt${_private_suffix}_COMPILE_DEFINITIONS
${Qt6${_module_dep}_COMPILE_DEFINITIONS})
endforeach()
unset(_private_suffix)
list(REMOVE_DUPLICATES Qt6Mqtt_INCLUDE_DIRS)
list(REMOVE_DUPLICATES Qt6Mqtt_PRIVATE_INCLUDE_DIRS)
list(REMOVE_DUPLICATES Qt6Mqtt_DEFINITIONS)
list(REMOVE_DUPLICATES Qt6Mqtt_COMPILE_DEFINITIONS)
endif()
if (TARGET Qt6::Mqtt)
qt_make_features_available(Qt6::Mqtt)
foreach(extra_cmake_include )
include("${CMAKE_CURRENT_LIST_DIR}/${extra_cmake_include}")
endforeach()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/Qt6MqttPlugins.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttPlugins.cmake")
endif()
list(APPEND QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE "Mqtt")
get_target_property(_qt_module_target_type "Qt6::Mqtt" TYPE)
if(NOT _qt_module_target_type STREQUAL "INTERFACE_LIBRARY")
get_target_property(_qt_module_plugin_types
Qt6::Mqtt MODULE_PLUGIN_TYPES)
if(_qt_module_plugin_types)
list(APPEND QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE "${_qt_module_plugin_types}")
endif()
endif()
# Load Module's BuildInternals should any exist
if (Qt6BuildInternals_DIR AND
EXISTS "${CMAKE_CURRENT_LIST_DIR}/Qt6MqttBuildInternals.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttBuildInternals.cmake")
endif()
if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
if(CMAKE_VERSION VERSION_LESS 3.18 OR QT_USE_OLD_VERSION_LESS_TARGETS)
include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttVersionlessTargets.cmake")
else()
include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttVersionlessAliasTargets.cmake")
endif()
endif()
else()
set(Qt6Mqtt_FOUND FALSE)
if(NOT DEFINED Qt6Mqtt_NOT_FOUND_MESSAGE)
set(Qt6Mqtt_NOT_FOUND_MESSAGE
"Target \"Qt6::Mqtt\" was not found.")
if(QT_NO_CREATE_TARGETS)
string(APPEND Qt6Mqtt_NOT_FOUND_MESSAGE
"Possibly due to QT_NO_CREATE_TARGETS being set to TRUE and thus "
"${CMAKE_CURRENT_LIST_DIR}/Qt6MqttTargets.cmake was not "
"included to define the target.")
endif()
endif()
endif()

View File

@ -0,0 +1,68 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Include the basic version config file to get results of regular version checking.
include("${CMAKE_CURRENT_LIST_DIR}/Qt6MqttConfigVersionImpl.cmake")
set(__qt_disable_package_version_check FALSE)
# Allow to opt out of the version check.
if(QT_NO_PACKAGE_VERSION_CHECK)
set(__qt_disable_package_version_check TRUE)
endif()
# Extra CMake code begin
# Extra CMake code end
if((NOT PACKAGE_VERSION_COMPATIBLE) OR PACKAGE_VERSION_UNSUITABLE)
set(__qt_package_version_incompatible TRUE)
else()
set(__qt_package_version_incompatible FALSE)
endif()
if(__qt_disable_package_version_check)
# Don't show the warning needlessly if we know that we're doing an exact search, and the
# version found is not the exactly same.
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT
AND NOT PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(QT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING TRUE)
endif()
# Warn if version check is disabled regardless if it's a Qt repo build or user project build.
# Allow to opt out of warning.
if(__qt_package_version_incompatible AND NOT QT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING
AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
message(WARNING
"Package ${PACKAGE_FIND_NAME} with version ${PACKAGE_VERSION} was accepted as "
"compatible because QT_NO_PACKAGE_VERSION_CHECK was set to TRUE. There is no guarantee "
"the build will succeed. You can silence this warning by passing "
"-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE")
endif()
# Mark version as compatible. This is how we disable the version check.
set(PACKAGE_VERSION_COMPATIBLE TRUE)
unset(PACKAGE_VERSION_UNSUITABLE)
# If QT_REPO_MODULE_VERSION is set, that means we are building a Qt repo. Show message that one can
# disable the check if they need to.
elseif(QT_REPO_MODULE_VERSION AND __qt_package_version_incompatible)
if(PACKAGE_FIND_VERSION_RANGE)
set(__qt_package_version_message_prefix "Version range ${PACKAGE_FIND_VERSION_RANGE}")
else()
set(__qt_package_version_message_prefix "Version ${PACKAGE_FIND_VERSION}")
endif()
message(WARNING
"${__qt_package_version_message_prefix} of package ${PACKAGE_FIND_NAME} was requested but "
"an incompatible version was found: ${PACKAGE_VERSION}. You can pass "
"-DQT_NO_PACKAGE_VERSION_CHECK=TRUE to disable the version check and force the "
"incompatible version to be used. There is no guarantee the build will succeed. "
"Use at your own risk. "
"You can silence this warning by passing -DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=TRUE")
endif()
unset(__qt_disable_package_version_check)
unset(__qt_disable_package_version_check_due_to_developer_build)
unset(__qt_package_version_message_prefix)
unset(__qt_package_version_incompatible)

View File

@ -0,0 +1,43 @@
# This is a basic version file for the Config-mode of find_package().
# It is used by write_basic_package_version_file() as input file for configure_file()
# to create a version-file which can be installed along a config.cmake file.
#
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
# the requested version string are exactly the same and it sets
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
# The variable CVF_VERSION must be set before calling configure_file().
set(PACKAGE_VERSION "6.8.0")
if (PACKAGE_FIND_VERSION_RANGE)
# Package version must be in the requested version range
if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
endif()
else()
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
endif()
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if(CMAKE_SIZEOF_VOID_P STREQUAL "" OR "8" STREQUAL "")
return()
endif()
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
math(EXPR installedBits "8 * 8")
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()

View File

@ -0,0 +1,46 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Make sure Qt6 is found before anything else.
set(Qt6Mqtt_FOUND FALSE)
if("${_qt_cmake_dir}" STREQUAL "")
set(_qt_cmake_dir "${QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR}")
endif()
set(__qt_use_no_default_path_for_qt_packages "NO_DEFAULT_PATH")
if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
set(__qt_use_no_default_path_for_qt_packages "")
endif()
# Don't propagate REQUIRED so we don't immediately FATAL_ERROR, rather let the find_dependency calls
# set _NOT_FOUND_MESSAGE which will be displayed by the includer of the Dependencies file.
set(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED FALSE)
if(NOT Qt6_FOUND)
find_dependency(Qt6 6.8.0
PATHS
${QT_BUILD_CMAKE_PREFIX_PATH}
"${CMAKE_CURRENT_LIST_DIR}/.."
"${_qt_cmake_dir}"
${_qt_additional_packages_prefix_paths}
${__qt_use_no_default_path_for_qt_packages}
)
endif()
# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
set(__qt_Mqtt_third_party_deps "")
_qt_internal_find_third_party_dependencies("Mqtt" __qt_Mqtt_third_party_deps)
# Find Qt tool package.
set(__qt_Mqtt_tool_deps "")
_qt_internal_find_tool_dependencies("Mqtt" __qt_Mqtt_tool_deps)
# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0"
set(__qt_Mqtt_target_deps "Qt6Core\;6.8.0;Qt6Network\;6.8.0")
set(__qt_Mqtt_find_dependency_paths "${CMAKE_CURRENT_LIST_DIR}/.." "${_qt_cmake_dir}")
_qt_internal_find_qt_dependencies("Mqtt" __qt_Mqtt_target_deps
__qt_Mqtt_find_dependency_paths)
set(_Qt6Mqtt_MODULE_DEPENDENCIES "Core;Network")
set(Qt6Mqtt_FOUND TRUE)

View File

@ -0,0 +1,100 @@
# Generated by CMake
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8)
message(FATAL_ERROR "CMake >= 2.8.0 required")
endif()
if(CMAKE_VERSION VERSION_LESS "2.8.3")
message(FATAL_ERROR "CMake >= 2.8.3 required")
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 2.8.3...3.24)
#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
if(CMAKE_VERSION VERSION_LESS 3.0.0)
message(FATAL_ERROR "This file relies on consumers using CMake 3.0.0 or greater.")
endif()
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_cmake_targets_defined "")
set(_cmake_targets_not_defined "")
set(_cmake_expected_targets "")
foreach(_cmake_expected_target IN ITEMS Qt6::Mqtt Qt6::MqttPrivate)
list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
if(TARGET "${_cmake_expected_target}")
list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
else()
list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
endif()
endforeach()
unset(_cmake_expected_target)
if(_cmake_targets_defined STREQUAL _cmake_expected_targets)
unset(_cmake_targets_defined)
unset(_cmake_targets_not_defined)
unset(_cmake_expected_targets)
unset(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)
return()
endif()
if(NOT _cmake_targets_defined STREQUAL "")
string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}")
string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}")
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n")
endif()
unset(_cmake_targets_defined)
unset(_cmake_targets_not_defined)
unset(_cmake_expected_targets)
# Create imported target Qt6::Mqtt
add_library(Qt6::Mqtt SHARED IMPORTED)
set_target_properties(Qt6::Mqtt PROPERTIES
COMPATIBLE_INTERFACE_STRING "QT_MAJOR_VERSION"
INTERFACE_COMPILE_DEFINITIONS "QT_MQTT_LIB"
INTERFACE_INCLUDE_DIRECTORIES "C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/include;C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/include/QtMqtt"
INTERFACE_LINK_LIBRARIES "Qt6::Core;Qt6::Network"
INTERFACE_QT_MAJOR_VERSION "6"
INTERFACE_SOURCES "\$<\$<BOOL:\$<TARGET_PROPERTY:QT_CONSUMES_METATYPES>>:C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/src/mqtt/meta_types/qt6mqtt_release_metatypes.json>"
_qt_config_module_name "mqtt"
_qt_is_public_module "TRUE"
_qt_module_has_headers "ON"
_qt_module_has_private_headers "TRUE"
_qt_module_has_public_headers "TRUE"
_qt_module_include_name "QtMqtt"
_qt_module_interface_name "Mqtt"
_qt_package_name "Qt6Mqtt"
_qt_package_version "6.8.0"
_qt_private_module_target_name "MqttPrivate"
)
# Create imported target Qt6::MqttPrivate
add_library(Qt6::MqttPrivate INTERFACE IMPORTED)
set_target_properties(Qt6::MqttPrivate PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/src/mqtt;\$<\$<BOOL:\$<TARGET_PROPERTY:Qt6::Mqtt,_qt_module_has_private_headers>>:C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/include/QtMqtt/6.8.0>;\$<\$<BOOL:\$<TARGET_PROPERTY:Qt6::Mqtt,_qt_module_has_private_headers>>:C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/include/QtMqtt/6.8.0/QtMqtt>;\$<\$<BOOL:\$<TARGET_PROPERTY:Qt6::Mqtt,_qt_module_has_private_headers>>:>;\$<\$<BOOL:\$<TARGET_PROPERTY:Qt6::Mqtt,_qt_module_has_private_headers>>:>"
INTERFACE_LINK_LIBRARIES "Qt6::CorePrivate;Qt6::Mqtt"
_qt_config_module_name "mqtt_private"
_qt_is_private_module "TRUE"
_qt_package_name "Qt6Mqtt"
_qt_package_version "6.8.0"
_qt_public_module_target_name "Mqtt"
)
# Import target "Qt6::Mqtt" for configuration "Release"
set_property(TARGET Qt6::Mqtt APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(Qt6::Mqtt PROPERTIES
IMPORTED_IMPLIB_RELEASE "C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/lib/libQt6Mqtt.a"
IMPORTED_LOCATION_RELEASE "C:/Users/qw200/Downloads/qtmqtt-dev/build/Desktop_Qt_6_8_0_MinGW_64_bit-Release/bin/Qt6Mqtt.dll"
)
# This file does not depend on other imported targets which have
# been exported from the same project but in a separate export set.
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)

View File

@ -0,0 +1,7 @@
# Protect against multiple inclusion, which would fail when already imported targets are
# added once more.
_qt_internal_check_multiple_inclusion(_targets_not_defined "Mqtt;MqttPrivate")
_qt_internal_create_versionless_alias_targets("${_targets_not_defined}" Qt6)
unset(_targets_not_defined)

View File

@ -0,0 +1,7 @@
# Protect against multiple inclusion, which would fail when already imported targets are
# added once more.
_qt_internal_check_multiple_inclusion(_targets_not_defined "Mqtt;MqttPrivate")
_qt_internal_create_versionless_targets("${_targets_not_defined}" Qt6)
unset(_targets_not_defined)

BIN
lib/libQt6Mqtt.a Normal file

Binary file not shown.

12
lib/pkgconfig/Qt6Mqtt.pc Normal file
View File

@ -0,0 +1,12 @@
prefix=/QT/6.8.0/mingw_64
exec_prefix=${prefix}
bindir=${prefix}/bin
libexecdir=${prefix}/./bin
libdir=${prefix}/lib
includedir=${prefix}/include
Name: Qt6 Mqtt
Description: Qt Mqtt module
Version: 6.8.0
Libs: -L${libdir} -lQt6Mqtt
Cflags: -I${includedir}/QtMqtt -I${includedir} -DQT_MQTT_LIB

View File

@ -0,0 +1,14 @@
prefix=/QT/6.8.0/mingw_64
exec_prefix=${prefix}
bindir=${prefix}/bin
libexecdir=${prefix}/./bin
libdir=${prefix}/lib
includedir=${prefix}/include
Name: Qt6 Mqtt
Description: Qt Mqtt module
Version: 6.8.0
Libs: -L${libdir} -lQt6Mqtt
Cflags: -I${includedir}/QtMqtt -I${includedir} -DQT_MQTT_LIB
Requires:

View File

@ -0,0 +1,14 @@
prefix=/QT/6.8.0/mingw_64
exec_prefix=${prefix}
bindir=${prefix}/bin
libexecdir=${prefix}/./bin
libdir=${prefix}/lib
includedir=${prefix}/include
$<$<BOOL:>:mkspecsdir=${prefix}/mkspecs>
$<1: >
Name: Qt6 Mqtt
Description: Qt Mqtt module
Version: 6.8.0
Libs: $<$<NOT:$<STREQUAL:$<TARGET_PROPERTY:Qt6::Mqtt,TYPE>,INTERFACE_LIBRARY>>:-L${libdir} -lQt6Mqtt> $<$<BOOL:loose_link_options-NOTFOUND>:$<JOIN:$<REMOVE_DUPLICATES:loose_link_options-NOTFOUND>, >> $<JOIN:$<REMOVE_DUPLICATES:>, >
Cflags: $<$<BOOL:${includedir}/QtMqtt;${includedir}>:-I$<JOIN:$<REMOVE_DUPLICATES:${includedir}/QtMqtt;${includedir}>, -I>> $<$<BOOL:QT_MQTT_LIB>:-D$<JOIN:$<REMOVE_DUPLICATES:QT_MQTT_LIB>, -D>>
Requires: $<JOIN:$<REMOVE_DUPLICATES:>, >

25
main.cpp Normal file
View File

@ -0,0 +1,25 @@
#include "mainwindow.h"
#include <QApplication>
#include <QLocale>
#include <QTranslator>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = "IOT_" + QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
a.installTranslator(&translator);
break;
}
}
MainWindow w;
w.show();
return a.exec();
}

312
mainwindow.cpp Normal file
View File

@ -0,0 +1,312 @@
#include <QInputDialog>
#include "mainwindow.h"
#include "qjsondocument.h"
#include "qjsonobject.h"
#include "qnetworkaccessmanager.h"
#include "qnetworkreply.h"
#include "ui_mainwindow.h"
#include <QApplication>
#include <QGroupBox>
#include <QPushButton>
#include <QVBoxLayout>
#include <QMessageBox>
#include <functional>
#include <QCloseEvent>
#include <QSettings>
QString newves33;
QString ves33="V1.0.0";
QString remainderx33;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowTitle("万物互联IOT桌面端");
// 恢复上次保存的按钮信息
restoreButtonSettings();
//更新检查连接
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QUrl url("api1url");
QNetworkRequest request(url);
// Set unsafe SSL configuration
QSslConfiguration config = request.sslConfiguration();
config.setPeerVerifyMode(QSslSocket::VerifyNone);
request.setSslConfiguration(config);
QNetworkReply *reply = manager->get(request);
// Connect to the finished signal
connect(reply, &QNetworkReply::finished, [=]() {
if (reply->error() == QNetworkReply::NoError) {
// Read the JSON data
QByteArray data = reply->readAll();
// Display the JSON data in a message box
QJsonDocument jsonDoc = QJsonDocument::fromJson(QString(data).toUtf8());
QJsonObject jsonObj = jsonDoc.object();
// 获取数据
QJsonObject jObj2 = jsonDoc["data"].toObject();
QString str = jObj2 ["content"].toString();
qDebug() << str;
newves33 = str.left(6); // 提取前6个字符组成newves
remainderx33 = str.mid(6); // 提取剩下的字符
remainderx33.replace("#", "\n");
qDebug() << "update1111111";
qDebug() << newves33;
qDebug() << ves33;
if (newves33 != ves33) {
// QMessageBox::warning(this, "Error", "已发布新版本\"" + info + "\"。\n点击\"设置\"下载最新版本。");
ui->pushButton->setText("发现新版本");
qDebug() << "update";
}
else {
// ui->pushButton_4->setText("暂无更新");
qDebug() << "no";
}
}
else {
// Display an error message
QMessageBox::warning(this, "Error", reply->errorString());
}
// Clean up
reply->deleteLater();
manager->deleteLater();
});
everyday();
everyEinglish();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
form* formDialog = new form("",ves33,newves33,remainderx33,this); // 使用其他名称替换 'form'
formDialog->show();
}
void MainWindow::onNewButtonClicked()
{
// 在新按钮被点击时执行的操作
qDebug() << "New Button Clicked";
}
void MainWindow::on_pushButton_2_clicked()
{
// 创建一个新的 addButton
// 创建输入对话框
bool ok;
QString buttonText = QInputDialog::getText(this, "添加设备", "请输入设备ID", QLineEdit::Normal, "", &ok);
// 如果用户点击了“OK”按钮则设置按钮的文本名称为输入的内容
if (ok && !buttonText.isEmpty()) {
if (buttonText.contains("fp")) {
QPushButton* newButton = new QPushButton("Add Button", ui->groupBox);
// 获取已存在的布局对象
QVBoxLayout* layout = ui->verticalLayout;
// 添加新的 addButton 到布局
layout->addWidget(newButton);
newButton->setText("Flowerpot\nID:"+buttonText);
// 连接新按钮的 clicked 信号到 lambda 函数
connect(newButton, &QPushButton::clicked, [=]() {
// 获取当前按钮的索引
int buttonIndex = layout->indexOf(newButton) + 1;
// 显示当前按钮的索引
// 如果 addButton 文本名称包含 "fp",则弹出相应的窗口
if (buttonText.contains("fp")) {
QString fpText = buttonText.mid(buttonText.indexOf("fp"));
Dialog* dialog = new Dialog(fpText, this);
dialog->show();
}
// 可以在这里添加其他点击按钮时的操作
});
}else{
QMessageBox::information(this, "设备ID错误", "设备ID错误检查你输入的设备ID是否正确" );
}
}
}
void MainWindow::saveButtonSettings()
{
// 获取已存在的布局对象
QVBoxLayout* layout = ui->verticalLayout;
// 创建 QSettings 对象,用于读写注册表信息
QSettings settings("IOT", "IOT");
// 清空注册表中的旧按钮信息
settings.remove("Buttons");
// 保存每个按钮的文本和索引
for (int i = 0; i < layout->count(); i++) {
QPushButton* button = qobject_cast<QPushButton*>(layout->itemAt(i)->widget());
if (button) {
QString buttonText = button->text();
settings.setValue(QString("Buttons/button%1Text").arg(i), buttonText);
}
}
}
void MainWindow::restoreButtonSettings()
{
// 获取已存在的布局对象
QVBoxLayout* layout = ui->verticalLayout;
// 创建 QSettings 对象,用于读写注册表信息
QSettings settings("IOT", "IOT");
// 遍历按钮索引,读取注册表中的按钮信息,并添加按钮到布局
int buttonIndex = 0;
while (true) {
QString buttonText = settings.value(QString("Buttons/button%1Text").arg(buttonIndex)).toString();
if (buttonText.isEmpty()) {
break; // 没有更多的按钮信息可读取,退出循环
}
QPushButton* newButton = new QPushButton(buttonText, ui->groupBox);
layout->addWidget(newButton);
// 连接按钮的 clicked 信号到槽函数
connect(newButton, &QPushButton::clicked, [=]() {
// 显示按钮索引
// QMessageBox::information(this, "Button Index", "This is button number " + QString::number(buttonIndex));
if (buttonText.contains("fp")) {
QString fpText = buttonText.mid(buttonText.indexOf("fp"));
Dialog* dialog = new Dialog(fpText, this);
dialog->show();
}
// 可以在这里添加按钮点击时的操作
});
buttonIndex++;
}
}
void MainWindow::closeEvent(QCloseEvent* event)
{
saveButtonSettings();
event->accept();
}
void MainWindow::everyday()
{
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QUrl url("updataurl");
QNetworkRequest request(url);
// Set unsafe SSL configuration
QSslConfiguration config = request.sslConfiguration();
config.setPeerVerifyMode(QSslSocket::VerifyNone);
request.setSslConfiguration(config);
QNetworkReply *reply = manager->get(request);
// Connect to the finished signal
connect(reply, &QNetworkReply::finished, [=]() {
if (reply->error() == QNetworkReply::NoError) {
// Read the JSON data
QByteArray data = reply->readAll();
// Display the JSON data in a message box
QJsonDocument jsonDoc = QJsonDocument::fromJson(QString(data).toUtf8());
QJsonObject jsonObj = jsonDoc.object();
// 获取数据
QString city = jsonObj["city"].toString();
QJsonObject jObj2 = jsonDoc["info"].toObject();
QString high = jObj2 ["high"].toString();
QString low = jObj2 ["low"].toString();
QString date = jObj2 ["date"].toString();
QString week = jObj2 ["week"].toString();
QString type = jObj2 ["type"].toString();
QJsonObject jObj23 = jObj2["air"].toObject();
QString aqiname = jObj23 ["aqi_name"].toString();
QString tip =jObj2["tip"].toString();
QString info = city+" "+date+" "+week+" "+type+"\n温度:"+low+"-"+high+" 空气质量:"+aqiname;
ui->label_2->setWordWrap(true);
ui->label_2->setText("每日天气:\n\n"+info);
}
else {
// Display an error message
QMessageBox::warning(this, "Error", reply->errorString());
}
// Clean up
reply->deleteLater();
manager->deleteLater();
});
}
void MainWindow::everyEinglish()
{
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QUrl url("api2url");
QNetworkRequest request(url);
// Set unsafe SSL configuration
QSslConfiguration config = request.sslConfiguration();
config.setPeerVerifyMode(QSslSocket::VerifyNone);
request.setSslConfiguration(config);
QNetworkReply *reply = manager->get(request);
// Connect to the finished signal
connect(reply, &QNetworkReply::finished, [=]() {
if (reply->error() == QNetworkReply::NoError) {
// Read the JSON data
QByteArray data = reply->readAll();
// Display the JSON data in a message box
QJsonDocument jsonDoc = QJsonDocument::fromJson(QString(data).toUtf8());
QJsonObject jsonObj = jsonDoc.object();
QJsonObject jObj2 = jsonDoc["data"].toObject();
QString key1Val = jObj2["zh"].toString();
QString key1Val2 = jObj2["en"].toString();
ui->label_3->setWordWrap(true);
ui->label_3->setText("每日英语:\n\n"+key1Val2);
// QMessageBox::information(this, "JSON Data", key1Val2);
} else {
// Display an error message
QMessageBox::warning(this, "Error", reply->errorString());
}
// Clean up
reply->deleteLater();
manager->deleteLater();
});
}
void MainWindow::on_pushButton_3_clicked()
{
// 获取信号的发送者
QVBoxLayout* layout = ui->verticalLayout;
QLayoutItem* item;
while ((item = layout->takeAt(0)) != nullptr) {
if (item->widget()) {
delete item->widget();
}
delete item;
}
}

39
mainwindow.h Normal file
View File

@ -0,0 +1,39 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "dialog.h"
#include "ui_dialog.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void onNewButtonClicked();
void on_pushButton_clicked();
void restoreButtonSettings();
void on_pushButton_2_clicked();
void saveButtonSettings();
void closeEvent(QCloseEvent*);
void everyday();
void everyEinglish();
void on_pushButton_3_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

135
mainwindow.ui Normal file
View File

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>633</width>
<height>382</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="1">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<underline>false</underline>
</font>
</property>
<property name="text">
<string>每日英语:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pushButton_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>添加设备</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="6">
<widget class="QGroupBox" name="groupBox">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string>我的设备</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout"/>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>今日天气:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>503</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:18pt;&quot;&gt;万物互联IOT设备PC控制中心&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="pushButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>498</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>检查更新</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="pushButton_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>删除全部设备</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>633</width>
<height>18</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>