-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
63 lines (43 loc) · 1.73 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQuickView>
#include <QQmlContext>
#include "quickandroid.h"
#include "qadrawableprovider.h"
#include "qasystemdispatcher.h"
#include <fileio.h>
#ifdef Q_OS_ANDROID
#include <QtAndroidExtras/QAndroidJniObject>
#include <QtAndroidExtras/QAndroidJniEnvironment>
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
Q_UNUSED(vm);
qDebug("NativeInterface::JNI_OnLoad()");
// It must call this function within JNI_OnLoad to enable System Dispatcher
QASystemDispatcher::registerNatives();
/* Optional: Register your own service */
// Call quickandroid.example.ExampleService.start()
QAndroidJniObject::callStaticMethod<void>("quickandroid/example/ExampleService",
"start",
"()V");
return JNI_VERSION_1_6;
}
#endif
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setOrganizationName("Some Company");
app.setOrganizationDomain("somecompany.com");
app.setApplicationName("Amazing Application");
QQmlApplicationEngine engine;
qmlRegisterType<FileIO>("org.example", 1, 0, "FileIO");
/* QuickAndroid Initialization */
engine.addImportPath("qrc:///"); // Add QuickAndroid into the import path
// Setup "drawable" image provider
QADrawableProvider* provider = new QADrawableProvider();
provider->setBasePath("qrc:///res/res"); //"qrc:////res"
engine.addImageProvider("drawable",provider);
/* End of QuickAndroid Initialization */
//engine.rootContext()->setContextProperty("MyString","QT + QML");
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}