cotton_double/main.cpp
2024-12-25 15:49:44 +08:00

39 lines
1.0 KiB
C++

#include "widget.h"
#include <QApplication>
#include <QDebug>
// 全局变量存储原始的消息处理器
QtMessageHandler originalHandler = nullptr;
// 自定义消息处理器
void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
// 过滤掉特定的警告信息
if (msg.contains("QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread")) {
return; // 不做任何处理,相当于抑制该消息
}
// 其他消息交给原始处理器
if (originalHandler) {
originalHandler(type, context, msg);
}
}
int main(int argc, char *argv[])
{
// // 调用 iniLowMac 函数初始化与下位机的连接
// if (!iniLowMac()) {
// qDebug() << "Failed to initialize connection.";
// return -1;
// }
QApplication a(argc, argv);
// 安装自定义消息处理器,保存原始处理器
originalHandler = qInstallMessageHandler(customMessageHandler);
Widget w;
w.show();
return a.exec();
}