调试修改MQTT通讯解析

This commit is contained in:
lixiaoyuan
2025-09-16 19:38:46 +08:00
parent 9377e7f8e6
commit 393f68aec9
25 changed files with 943 additions and 1428 deletions

View File

@@ -10,6 +10,7 @@
#include <QToolBar>
#include <QMouseEvent>
#include <QHBoxLayout>
#include <QNetworkProxyFactory>
#include "common/Spdlogger.h"
@@ -45,6 +46,9 @@ void MySplash(MainWeb* mainWin)
MainWeb::MainWeb()
{
QNetworkProxyFactory::setUseSystemConfiguration(false);
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
this->setWindowTitle("光储充站监控与运营管理平台");
this->setGeometry(0, 0, 1920, 1080);
this->hide();
@@ -85,8 +89,8 @@ void MainWeb::initWebview()
labelWebErr.setStyleSheet("font: bold 20px;");
labelWebErr.hide();
qputenv("QTWEBENGINE_REMOTE_DEBUGGING", "9222"); // 即使内置视图,有时也需要开启调试端口
//this->setCentralWidget(&webView);
this->setCentralWidget(&webView);
webView.setParent(this);
webView.setGeometry(0, 0, 1920, 1080);
@@ -102,8 +106,10 @@ void MainWeb::initWebview()
//webView.setContextMenuPolicy(Qt::NoContextMenu);
webView.load(QUrl(Config::option.webSrvUrl.c_str()));
webView.hide();
// 将主 Web 页面的开发者工具页面设置为 devToolsView 的页面
webView.page()->setDevToolsPage(devTools.page());
//qputenv("QTWEBENGINE_REMOTE_DEBUGGING", "9222"); // 即使内置视图,有时也需要开启调试端口
//webView.page()->setDevToolsPage(devTools.page());
QObject::connect(&webView, &QWebEngineView::loadFinished, [=](bool ok)
{
@@ -168,6 +174,15 @@ void MainWeb::showDevTools()
}
else
{
qputenv("QTWEBENGINE_REMOTE_DEBUGGING", "9222"); // 即使内置视图,有时也需要开启调试端口
webView.page()->setDevToolsPage(devTools.page());
QWidget* w = new QWidget;
w->resize(800, 900);
devTools.setParent(w);
devTools.resize(800, 900);
w->show();
// 如果你需要先导航主页面,然后在某个事件(如按钮点击)后显示开发者工具,可以将这行代码放在事件处理函数中。
layout = new QHBoxLayout(this);
// 将两个视图添加到布局中
@@ -201,6 +216,7 @@ void MainWeb::keyPressEvent(QKeyEvent* e)
}
else if (key == Qt::Key_F5)
{
webView.load(QUrl(Config::option.webSrvUrl.c_str()));
webView.update();
//webView.load(QUrl(Config::option.webSrvUrl.c_str()));
}
}

View File

@@ -5,7 +5,7 @@
#include <QPushButton>
#include <QHBoxLayout>
class MainWeb : public QWidget
class MainWeb : public QMainWindow
{
Q_OBJECT
public: