#include "widget.h" #include #include // 全局变量存储原始的消息处理器 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); // QFile file("C:/Users/Administrator/Documents/cotton_double/styles/style.qss"); // 或者使用文件路径 // if (file.open(QFile::ReadOnly)) { // QString styleSheet = QLatin1String(file.readAll()); // qApp->setStyleSheet(styleSheet); // } Widget w; w.show(); return a.exec(); }