-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
31 lines (23 loc) · 792 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QUrl>
int main(int argc, char *argv[]) {
if (argc <= 1) {
printf("qmlscreenshot inputQmlFile outImageFile \n");
return 1;
}
QString inputQmlFile,outImageFile;
inputQmlFile = argc >=1 ? argv[1] : "";
if (argc > 2 ) {
outImageFile = argv[2];
} else if (argc == 2) {
outImageFile = inputQmlFile+".png";
}
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("inputQmlFile", QVariant(QUrl::fromLocalFile(inputQmlFile)));
engine.rootContext()->setContextProperty("outImageFile", QVariant(outImageFile));
engine.load(QUrl("qrc:/main.qml"));
return app.exec();
}