1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #include <QGuiApplication>
- #include <QGuiApplication>
- #include <QQmlApplicationEngine>
- #include <QQmlContext>
- #include "addressbookengine.h"
- #include "addressbook.qpb.h"
- #include <QMetaProperty>
- #include <QQmlPropertyMap>
- using namespace qtprotobuf::examples;
- int main(int argc, char *argv[])
- {
- QtProtobuf::qRegisterProtobufTypes();
- QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
- qmlRegisterType<ContactsListModel>("examples.addressbook", 1, 0, "ContactsListModel");
- QGuiApplication app(argc, argv);
- qmlRegisterSingletonType<AddressBookEngine>("examples.addressbook", 1, 0, "AddressBookEngine", [](QQmlEngine *engine, QJSEngine *) -> QObject *{
- static AddressBookEngine abEngine;
- engine->setObjectOwnership(&abEngine, QQmlEngine::CppOwnership);
- return &abEngine;
- });
- QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
- if (engine.rootObjects().isEmpty())
- return -1;
- return app.exec();
- }
|