当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.cpp 2.07 KB
一键复制 编辑 原始数据 按行查看 历史
SSSSSSSan 提交于 2022-08-01 02:12 . 兼容Qt5
#include "mainwindow.h"
#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include <QSysInfo>
#include "define.h"
#include <qt_windows.h>
int main(int argc, char *argv[])
{
qDebug()<<QSysInfo::kernelType()<<QSysInfo::kernelVersion()<<QSysInfo::buildAbi()<<QSysInfo::machineUniqueId()<<QSysInfo::productType()<<QSysInfo::productVersion();
qDebug()<<QSysInfo::productType()<<QSysInfo::productVersion();//"windows" "11"
//禁止缩放(
//QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
//高分适配
//QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
//qputenv("QT_ENABLE_HIGHDPI_SCALING", "1");
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
QApplication a(argc, argv);
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = "dtUpdateV2_" + QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
a.installTranslator(&translator);
break;
}
}
QString tem="";
for(int i = 1; i< argc;++i)
{
//qDebug()<<i<<argv[i];
if(i<2)
{
tem =QString::fromLocal8Bit(argv[i]);
}else{
tem = tem+" "+QString::fromLocal8Bit(argv[i]);
}
}
if(tem.indexOf("?")>0)//唉
{
qDebug()<<"宽字符传参";
LPWSTR s=GetCommandLineW();
LPWSTR *cmdLineAry=CommandLineToArgvW(s,&argc);
for(int i = 1; i< argc;++i)
{
if(i<2)
{
tem =QString::fromStdWString(cmdLineAry[i]);
}else{
tem = tem+" "+QString::fromStdWString(cmdLineAry[i]);
}
}
}
qDebug().noquote()<<"传参路径:"<<tem;
MainWindow w;
w.setWorkPath(tem);
w.setWindowTitle(mainWindowTitle);
w.show();
return a.exec();
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化