修复bug
This commit is contained in:
parent
2b72bd1a7f
commit
7d2e4714f0
@ -16,6 +16,7 @@
|
||||
#include <stdio.h>
|
||||
#include <QSysInfo>
|
||||
#include <qsettings.h>
|
||||
#include <QNetworkProxy>
|
||||
#include "relaysetting.h"
|
||||
#include "common.h"
|
||||
QString g_strServerIp;
|
||||
@ -157,11 +158,19 @@ void MainWindow::createMenu(const QString& rootTitle, QPushButton* parent )
|
||||
QAction *reset = mainMenu->addAction("重置模块");
|
||||
QAction *upgrade = mainMenu->addAction("升级固件");
|
||||
QAction *version = mainMenu->addAction("查看版本");
|
||||
// 绑定 **鼠标事件过滤器**,确保只响应右键
|
||||
// 设置右键菜单策略
|
||||
parent->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(parent,&QPushButton::customContextMenuRequested,[=](const QPoint &pos)
|
||||
|
||||
// 使用 `customContextMenuRequested` 事件,确保只有右键点击时弹出菜单
|
||||
connect(parent, &QPushButton::customContextMenuRequested, this, [=](const QPoint &pos)
|
||||
{
|
||||
qDebug() << pos << endl;
|
||||
qDebug() << "右键菜单触发1:" << pos;
|
||||
|
||||
// 弹出菜单并捕获右键点击
|
||||
mainMenu->exec(QCursor::pos());
|
||||
|
||||
mainMenu->close();
|
||||
});
|
||||
// 连接所有菜单项
|
||||
QObject::connect(proximitor_1, &QAction::triggered,this, &MainWindow::onMenuActionTriggered);
|
||||
@ -343,8 +352,6 @@ void MainWindow::onMenuActionTriggered()
|
||||
}else if(action->text() == "查看版本"){
|
||||
getVersion(button_id - 3);
|
||||
}
|
||||
clearMenuProperties(button->menu());
|
||||
createMenu();
|
||||
break; // 找到按钮后,跳出循环
|
||||
}
|
||||
// 如果没有找到按钮,继续向上查找
|
||||
@ -496,7 +503,10 @@ void MainWindow::sendUpgradePackage(int slot)
|
||||
QTcpSocket socket;
|
||||
|
||||
// 连接到服务器
|
||||
QNetworkProxy proxy;
|
||||
proxy.setType(QNetworkProxy::NoProxy); // 不使用代理
|
||||
socket.connectToHost(g_strServerIp, 10000);
|
||||
socket.setProxy(proxy);
|
||||
if (!socket.waitForConnected()) {
|
||||
qDebug() << "Connection failed!";
|
||||
return;
|
||||
@ -588,7 +598,10 @@ void MainWindow::getVersion(int slot)
|
||||
// 连接到服务器
|
||||
QTcpSocket socket;
|
||||
// 连接到服务器
|
||||
QNetworkProxy proxy;
|
||||
proxy.setType(QNetworkProxy::NoProxy); // 不使用代理
|
||||
socket.connectToHost(g_strServerIp, 10000);
|
||||
socket.setProxy(proxy);
|
||||
if (!socket.waitForConnected()) {
|
||||
qDebug() << "Connection failed!";
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user