标签:show roo size EAP class div qt quick 启动 lap
现有两种启动Qt Quick App 模式:
qt默认使用第一种方法。
QQmlApplicationEngine搭配Window:
1 #include <QGuiApplication> 2 #include <QQmlApplicationEngine> 3 4 int main(int argc, char *argv[]) 5 { 6 #if defined(Q_OS_WIN) 7 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 8 #endif 9 10 QGuiApplication app(argc, argv); 11 12 QQmlApplicationEngine engine; 13 engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 14 if (engine.rootObjects().isEmpty()) 15 return -1; 16 17 return app.exec(); 18 }
QQuickView搭配Item:
#include <QGuiApplication> #include <QQuickView> int main(int argc, char *argv[]) { #if defined(Q_OS_WIN) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif QGuiApplication app(argc, argv); QQuickView viewer; viewer.setResizeMode(QQuickView::SizeRootObjectToView); viewer.setSource(QUrl("qrc:///main.qml")); viewer.show(); return app.exec(); }
——来自《Qt Quick核心编程》4.1.2
qml-main.cpp中的两种启动Qt Quick App模式
标签:show roo size EAP class div qt quick 启动 lap
原文地址:https://www.cnblogs.com/mxydsg8858/p/12291631.html