You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB
C++

#include "weighui.h"
#include <QApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QDebug>
#include <QDir>
int main(int argc, char *argv[])
{
// 使用 linuxfb 平台
qputenv("QT_QPA_PLATFORM", "linuxfb");
qputenv("QT_PLUGIN_PATH", "/userdata/lib/qt/plugins");
QApplication a(argc, argv);
// ── 解析命令行参数 ──
QCommandLineParser parser;
parser.setApplicationDescription("WeighUI - 称重系统 UI");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption domainOpt(QStringList() << "d" << "domain",
"DDS domain id (default 0).",
"id", "0");
parser.addOption(domainOpt);
parser.process(a);
bool ok = false;
int domainId = parser.value(domainOpt).toInt(&ok);
if (!ok || domainId < 0) {
qWarning() << "Invalid --domain value:" << parser.value(domainOpt)
<< ", fallback to 0";
domainId = 0;
}
qDebug() << "WeighUI 启动, DDS domain =" << domainId;
WeighUI w(domainId);
w.show();
return a.exec();
}