学习views例程,main.cpp中只有两句:
DECLARATIVE_EXAMPLE_MAIN 在shared.h中的定义如下:
#define DECLARATIVE_EXAMPLE_MAIN(NAME) int main(int argc, char* argv[]) \
{\
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);\
QGuiApplication app(argc,argv);\
app.setOrganizationName("QtProject");\
app.setOrganizationDomain("qt-project.org");\
app.setApplicationName(QFileInfo(app.applicationFilePath()).baseName());\
QQuickView view;\
if (qgetenv("QT_QUICK_CORE_PROFILE").toInt()) {\
QSurfaceFormat f = view.format();\
f.setProfile(QSurfaceFormat::CoreProfile);\
f.setVersion(4, 4);\
view.setFormat(f);\
}\
if (qgetenv("QT_QUICK_MULTISAMPLE").toInt()) {\
QSurfaceFormat f = view.format();\
f.setSamples(4);\
view.setFormat(f);\
}\
view.connect(view.engine(), &QQmlEngine::quit, &app, &QCoreApplication::quit);\
new QQmlFileSelector(view.engine(), &view);\
view.setSource(QUrl("qrc:///" #NAME ".qml")); \
if (view.status() == QQuickView::Error)\
return -1;\
view.setResizeMode(QQuickView::SizeRootObjectToView);\
view.show();\
return app.exec();\
}