1 Star 0 Fork 3

蜗牛的路/serialQuickCore

forked from 王徐晓/serialQuickCore 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.cpp 4.39 KB
一键复制 编辑 原始数据 按行查看 历史
//#include <QGuiApplication>
//#include <QQmlApplicationEngine>
//#include <qqmlengine.h>
//#include <qqmlcontext.h>
//#include <qqml.h>
//#include <QtQuick/qquickitem.h>
//#include <QtQuick/qquickview.h>
//#include <QFontDatabase>
//#include <QQmlContext>
//#include <QSettings>
//#include <QQuickStyle>
//#include <QIcon>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QSettings>
#include <QQuickStyle>
#include <QIcon>
#include <QFontDatabase>
#include <QtQuickControls2>
#include "qmlconncpp.h"
#include "../serialQuickCommon/globalobject.h"
qmlConnCpp qmlconncpp;
int main(int argc, char *argv[])
{
GlobalObject::objectInit();
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
QGuiApplication::setApplicationName("Gallery");
QGuiApplication::setOrganizationName("QtProject");
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
//设置默认字体
QFont font;
font.setPixelSize(10);
font.setFamily("Microsoft YaHei");
app.setFont(font);
QIcon::setThemeName("gallery");
#if defined(Q_OS_WIN32)
QSettings settings;
QString style = QQuickStyle::name();
if (!style.isEmpty())
settings.setValue("style", style);
else
QQuickStyle::setStyle(settings.value("style").toString());//该代码在嵌入式系统中出错
#elif defined(Q_OS_LINUX)
#endif
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("station", &station);
engine.rootContext()->setContextProperty("qmlconncpp", &qmlconncpp);
engine.rootContext()->setContextProperty("portlist", &portlist);
engine.rootContext()->setContextProperty("devicelist",&(devicelist));
engine.rootContext()->setContextProperty("hostlist",&(hostlist));
engine.rootContext()->setContextProperty("codelist",&(codelist));
#if defined(Q_OS_WIN32)
engine.rootContext()->setContextProperty("availableStyles", QQuickStyle::availableStyles());//该代码在嵌入式系统中出错
#elif defined(Q_OS_LINUX)
#endif
engine.load(QUrl("qrc:/serialQuickDemo/gallery.qml"));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
//int main(int argc, char *argv[])
//{
// GlobalObject::objectInit();
// qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
// QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// QGuiApplication app(argc, argv);
// //设置默认字体
// QFont font;
// font.setPixelSize(10);
// font.setFamily("Microsoft YaHei");
// app.setFont(font);
// QIcon::setThemeName("gallery");
// //qmlRegisterType<SerialPort>("an.qt.mySerialPort",1,0,"SerialPort");
// //qmlRegisterType<SerialPortHelper>("an.qt.mySerialPortHelper",1,0,"SerialPortHelper");
// //qRegisterMetaType<DeviceList>("DeviceList");
// //qRegisterMetaType<QList<Device>>("QList<Device>");
// //qmlRegisterType<Station>("an.qt.Station",1,0,"Station");
// //调试出系统字体列表
//// QFontDatabase database;
//// foreach (const QString &family, database.families(QFontDatabase::SimplifiedChinese))
//// {
//// qDebug()<<family;
//// }
// QSettings settings;
// QString style = QQuickStyle::name();
// if (!style.isEmpty())
// settings.setValue("style", style);
// else
// QQuickStyle::setStyle(settings.value("style").toString());
// QQmlApplicationEngine engine;
// engine.rootContext()->setContextProperty("station", &station);
// engine.rootContext()->setContextProperty("qmlconncpp", &qmlconncpp);
// engine.rootContext()->setContextProperty("portlist", &portlist);
// engine.rootContext()->setContextProperty("devicelist",&(devicelist));
// engine.rootContext()->setContextProperty("hostlist",&(hostlist));
// engine.rootContext()->setContextProperty("availableStyles", QQuickStyle::availableStyles());
// engine.load(QUrl("qrc:/serialQuickDemo/gallery.qml"));
// if (engine.rootObjects().isEmpty())
// return -1;
//// const QUrl url(QStringLiteral("qrc:/serialQuickDemo/gallery.qml"));
//// QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
//// &app, [url](QObject *obj, const QUrl &objUrl) {
//// if (!obj && url == objUrl)
//// QCoreApplication::exit(-1);
//// }, Qt::QueuedConnection);
//// engine.load(url);
// return app.exec();
//}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/492228993/serialQuickCore.git
git@gitee.com:492228993/serialQuickCore.git
492228993
serialQuickCore
serialQuickCore
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385