#include "mainwindow.h" #include "loginwindow.h" #include "logger.h" #include "fireWidget/firingwidget.h" #include #include #include #include // 关键头文件 int main(int argc, char *argv[]) { QApplication app(argc, argv); QQuickWindow::setSceneGraphBackend("software"); // 兼容性: 禁用GPU /*TODO: delete * QString jsonString = "{\"app_version\":\"1.52\",\"blast_latitude\":\"30.21122186731856\",\"blast_longitude\":\"120.22146062951883\",\"blast_time\":\"2025-05-29 16:02:32\",\"company_code\":\"3701234300003\",\"equipment_sn\":\"F34A0000001\",\"error_deto_count\":\"0\",\"operator_identity\":\"330781198509079292\",\"operator_name\":\"栋工\",\"phone\":\"18611112222\",\"project_htid\":\"\",\"project_name\":\"sidf\",\"project_xmbh\":\"\",\"reg_deto_count\":\"2\",\"regs\":[{\"after_test_bus_i\":\"41\",\"after_test_bus_v\":\"8006\",\"before_blasting_i\":\"49\",\"before_blasting_v\":\"13492\",\"bus_leakage_current_i\":\"0\",\"dets\":[{\"delay_time\":\"0.0\",\"freq\":\"0\",\"in_code\":\"005AC8360A4C01A7\",\"out_code\":\"2411104F18000\",\"status\":\"0x00\",\"tag\":\"1-1-1\",\"uid\":\"24211104F18000\"},{\"delay_time\":\"80.0\",\"freq\":\"0\",\"in_code\":\"015AC8360A4C014E\",\"out_code\":\"2411104F18001\",\"status\":\"0x00\",\"tag\":\"1-2-1\",\"uid\":\"24211104F18001\"}],\"equipment_sn\":\"null\",\"equipment_version\":\"null\",\"error_deto_count\":\"0\",\"net_charged_i\":\"49\",\"net_charged_v\":\"13501\",\"reg_deto_count\":\"2\"}]}"; // 使用 QJsonDocument::fromJson 直接解析 QByteArray 并获取 QJsonObject // 这是一个非常简洁的单行操作,假设你知道顶层是 JSON 对象且不关心详细的错误信息 QJsonObject myJsonObject = QJsonDocument::fromJson(jsonString.toUtf8()).object(); qDebug() <<"debug" << QDateTime::fromString(myJsonObject["blast_time"].toString(), "yyyy-MM-dd hh:mm:ss").toString(); qDebug() <<"debug" << QDateTime::fromString(myJsonObject["blast_time"].toString(), "yyyy-MM-dd hh:mm:ss").toString(Qt::ISODateWithMs); */ // 加载 QSS 文件 QFile styleFile(":/qss/qss/tableview.qss"); if (styleFile.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream stream(&styleFile); QString styleSheet = stream.readAll(); app.setStyleSheet(styleSheet); styleFile.close(); } // // 获取屏幕信息 // QScreen *screen = QGuiApplication::primaryScreen(); // QRect screenGeometry = screen->geometry(); // int screenWidth = screenGeometry.width(); // int screenHeight = screenGeometry.height(); // logger Logger::getInstance("application.log"); Logger::getInstance().setMaxFileSize(2 * 1024 * 1024); // 2 MB Logger::getInstance().setMaxBackupFiles(3); // Keep 3 backup files Logger::getInstance().info("Application started from main."); //MainWindow w; // Page w; // pageTest w; LoginWindow w; //loginWindow.show(); // 设置应用程序图标 app.setWindowIcon(QIcon(":/icons/icons/l634z-aceaj-001.ico")); // w.resize(screenWidth * 1, screenHeight * 0.95); // firingWidget w; w.show(); return app.exec(); }