本文整理汇总了C++中QmlApplicationViewer::engine方法的典型用法代码示例。如果您正苦于以下问题:C++ QmlApplicationViewer::engine方法的具体用法?C++ QmlApplicationViewer::engine怎么用?C++ QmlApplicationViewer::engine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QmlApplicationViewer
的用法示例。
在下文中一共展示了QmlApplicationViewer::engine方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// Localization: Loads the application translation depending on the mobile language.
QTranslator translator;
QString locale = QLocale::system().name();
translator.load("qml_" + locale, ":/qml/i18n/");
app.installTranslator(&translator);
UserAgentProvider p;
QString userAgent = p.getUserAgent();
NetworkAccessManagerFactory factory(userAgent);
QmlApplicationViewer viewer;
viewer.engine()->setNetworkAccessManagerFactory(&factory);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
viewer.setSource(QUrl("qrc:///qml/main.qml"));
// Performance operations
viewer.setAttribute(Qt::WA_OpaquePaintEvent);
viewer.setAttribute(Qt::WA_NoSystemBackground);
viewer.viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
viewer.viewport()->setAttribute(Qt::WA_NoSystemBackground);
viewer.window()->showFullScreen();
viewer.engine()->networkAccessManager()->cache()->clear();
return app.exec();
}
示例2: main
int main(int argc, char *argv[]) {
QScopedPointer<QApplication> app(createApplication(argc, argv));
qmlRegisterType<TileData>();
Core* game = new Core;
QmlApplicationViewer viewer;
viewer.engine()->rootContext()->setContextObject(game);
viewer.engine()->rootContext()->setContextProperty("core", game);
viewer.addImportPath(QLatin1String("modules")); // ADDIMPORTPATH
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait); // ORIENTATION
viewer.setMainQmlFile(QLatin1String("qml/main.qml")); // MAINQML
viewer.showExpanded();
return app->exec();
}
示例3: main
Q_DECL_EXPORT int main(int argc, char *argv[]) {
QApplication *lApplication = createApplication(argc, argv);
QmlApplicationViewer *lView = QmlApplicationViewer::create();
QVariantList lLevelList;
createAllLevels(lLevelList);
lView->rootContext()->setContextProperty(QLatin1String("gLevels"), lLevelList);
QNetworkAccessManager lNetworkManager;
LevelModel *lLevelModel = new LevelModel(lLevelList.count(), &lNetworkManager, lApplication);
lView->rootContext()->setContextProperty(QLatin1String("gLevelModel"), lLevelModel);
HighScoresModel *lHighScoresModel = new HighScoresModel(lApplication);
lView->rootContext()->setContextProperty(QLatin1String("gHighScoresModel"), lHighScoresModel);
QObject::connect(lLevelModel, SIGNAL(postingSucceded()), lHighScoresModel, SLOT(readScoresFromFile()));
QObject::connect(lView->engine(), SIGNAL(quit()), lApplication, SLOT(quit()));
qmlRegisterType<LevelHighScoresModel>("ChimpModels", 1, 0, "LevelHighScoreModel");
LevelHighScoresModel::registerOtherModels(lLevelModel, lHighScoresModel);
lView->setMainQmlFile(QLatin1String("qml/Game.qml"));
lView->showFullScreen();
return lApplication->exec();
}
示例4: main
int main(int argc, char *argv[])
{
// Depending on which is the recommended way for the platform, either use
// opengl graphics system or paint into QGLWidget.
#ifdef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM
QApplication::setGraphicsSystem("opengl");
#endif
QApplication app(argc, argv);
QmlApplicationViewer viewer;
#ifndef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM
QGLFormat format = QGLFormat::defaultFormat();
format.setSampleBuffers(false);
format.setSwapInterval(1);
QGLWidget* glWidget = new QGLWidget(format);
glWidget->setAutoFillBackground(false);
viewer.setViewport(glWidget);
#endif
viewer.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
viewer.setAttribute(Qt::WA_OpaquePaintEvent);
viewer.setAttribute(Qt::WA_NoSystemBackground);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
viewer.setMainQmlFile(QLatin1String("qml/shadereffects/main.qml"));
QObject::connect(viewer.engine(), SIGNAL(quit()), &viewer, SLOT(close()));
viewer.showExpanded();
return app.exec();
}
示例5: main
int main(int argc, char ** argv)
{
QUrl source("qml/networkaccessmanagerfactory/view.qml");
QApplication app(argc, argv);
QmlApplicationViewer viewer;
for (int i = 1; i < argc; ++i) {
QString arg(argv[i]);
if (arg == "-host" && i < argc-1) {
proxyHost = argv[++i];
} else if (arg == "-port" && i < argc-1) {
arg = argv[++i];
proxyPort = arg.toInt();
} else if (arg[0] != '-') {
source = QUrl::fromLocalFile(arg);
} else {
qWarning() << "Usage: networkaccessmanagerfactory [-host <proxy> -port <port>] [file]";
exit(1);
}
}
viewer.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
viewer.setMainQmlFile(source.toString());
viewer.showExpanded();
return app.exec();
}
示例6: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> App(createApplication(argc, argv));
QTranslator Translator;
if (!Translator.load("tr_"+QLocale::system().name(), ":/i18n"))
Translator.load("tr_en", ":/i18n");
App->installTranslator(&Translator);
ConTranslator ConsoleMsgs;
ConsoleMsgs.load("conmsgs", ":/i18n");
App->installTranslator(&ConsoleMsgs);
IconProvider::SetToCurrentSystemTheme();
Context Ctx(argc, argv);
ScopedIntercomHandler Intercom;
if (Ctx.IfExit())
return Intercom->GetExitCode();
{
ModesModel ModesList(Ctx.CheckMode(), Ctx.CheckMode()==RunModes::PRINT);
UsersModel UsersList(Ctx.GetTargetUser(), Ctx.CheckMode()==RunModes::PRINT);
DesktopModel AppList;
PswTools PassCheck;
QmlApplicationViewer Viewer;
qmlRegisterUncreatableType<RunModes>("com.lcferrum.hmtsu", 1, 0, "RunModes", "Exports RunModes enum to QML");
Viewer.engine()->addImageProvider("icon", new IconProvider()); //It is QDeclarativeEngine's responsibility to destroy added image providers
Viewer.rootContext()->setContextProperty("objModesList", &ModesList);
Viewer.rootContext()->setContextProperty("objUsersList", &UsersList);
Viewer.rootContext()->setContextProperty("objAppList", &AppList);
Viewer.rootContext()->setContextProperty("objContext", &Ctx);
Viewer.rootContext()->setContextProperty("objIntercom", &Intercom);
Viewer.rootContext()->setContextProperty("objPassCheck", &PassCheck);
Viewer.rootContext()->setContextProperty("HMTSU_VERSION_STRING", HMTSU_VERSION_STRING IF_DEBUG(" (DEBUG)"));
Viewer.rootContext()->setContextProperty("HMTSU_COPYRIGHT_STRING", HMTSU_COPYRIGHT_STRING);
Viewer.rootContext()->setContextProperty("CANCELED_EXIT_CODE", CANCELED_EXIT_CODE);
Viewer.rootContext()->setContextProperty("DENIED_EXIT_CODE", DENIED_EXIT_CODE);
Viewer.rootContext()->setContextProperty("NORMAL_EXIT_CODE", NORMAL_EXIT_CODE);
Viewer.rootContext()->setContextProperty("MAX_PSW_ATTEMPTS", MAX_PSW_ATTEMPTS);
Viewer.setSource(QUrl("qrc:/main.qml"));
Viewer.showExpanded();
App->exec();
}
Ctx.Run();
return Intercom->GetExitCode();
}
示例7: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
ImageProvider engine;
QmlApplicationViewer viewer;
viewer.rootContext()->setContextProperty("imageengine",(QObject*)&engine);
viewer.engine()->addImageProvider(QLatin1String("sortedimages"),&engine);
viewer.setMainQmlFile(QLatin1String("qml/Imagesort/main.qml"));
viewer.showExpanded();
return app->exec();
}
示例8: main
QTM_USE_NAMESPACE
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QCoreApplication::setOrganizationName("Synchroma");
QCoreApplication::setOrganizationDomain("synchroma.com.au");
QCoreApplication::setApplicationName("Arca");
QScopedPointer<QApplication> app(createApplication(argc, argv));
QmlApplicationViewer viewer;
QDeclarativeEngine *engine = viewer.engine();
QDeclarativeContext *context = engine->rootContext();
DBSession session;
session.setConsumerKey(DROPBOX_APP_KEY);
session.setConsumerSecret(DROPBOX_APP_SECRET);
// Have the REST client visible in the QML
DBRestClient restClient(session);
context->setContextProperty("restClient", &restClient);
// TESTING
context->setContextProperty("param", QString(argv[1]));
// TESTING
qDebug() << "temp dir: " << QDir::tempPath();
qDebug() << "home dir: " << QDir::homePath();
qDebug() << "current dir: " << QDir::currentPath();
QServiceManager serviceManager(QService::SystemScope);
QStringList stringList = serviceManager.findServices();
foreach (QString interfaceName, stringList)
qDebug() << "service interface: " << interfaceName;
QList<QServiceInterfaceDescriptor> descriptors = serviceManager.findInterfaces();
for (int i=0; i<descriptors.count(); i++)
{
QString service = descriptors[i].serviceName();
if (descriptors[i].scope() == QService::SystemScope)
service += " (system)";
qDebug() << "service: " << service;
}
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
viewer.setMainQmlFile(QLatin1String("qml/arca/main.qml"));
viewer.showExpanded();
return app->exec();
}
示例9: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QmlApplicationViewer viewer;
qmlRegisterType<TileData>();
MinehuntGame* game = new MinehuntGame();
viewer.engine()->rootContext()->setContextObject(game);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
viewer.setMainQmlFile(QLatin1String("qml/minehunt/minehunt.qml"));
viewer.showExpanded();
return app.exec();
}
示例10: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
app->setApplicationName ("9News");
app->setOrganizationName ("Stars");
app->setApplicationVersion ("0.0.1");
qmlRegisterType<SelectFilesDialog>("com.stars.widgets", 1, 0, "FilesDialog");
QmlApplicationViewer viewer;
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
viewer.engine()->rootContext()->setContextProperty("fileDialog", new SelectFilesDialog());
#ifdef HARMATTAN_BOOSTER
viewer.setMainQmlFile(QLatin1String("qml/meego/main.qml"));
#else
viewer.setMainQmlFile(QLatin1String("qml/symbian/main.qml"));
#endif
viewer.showExpanded();
return app->exec();
}
示例11: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
qmlRegisterType<Dict>("Vortaro", 1, 0, "Dict");
qmlRegisterType<Word>("Vortaro", 1, 0, "Word");
QScopedPointer<QApplication> app(createApplication(argc, argv));
QmlApplicationViewer viewer;
QDeclarativeEngine *engine = viewer.engine();
QDeclarativeContext *rootContext = engine->rootContext();
// engine->addImportPath(QString("/opt/nokia/qtsdk/Simulator/Qt/gcc/imports"));
Session session;
session.load();
rootContext->setContextObject(&session);
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
viewer.setSource(QUrl("qrc:///qml/main.qml"));
// viewer.setMainQmlFile(QString("qml/main.qml"));
viewer.showExpanded();
return app->exec();
}
示例12: main
int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
#ifdef Q_OS_SYMBIAN
// Translation for NFC Status messages
QString locale = QLocale::system().name();
QTranslator translator;
translator.load(QString("nfcinteractor_") + locale);
app->installTranslator(&translator);
QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
#endif
// Create a variable that stores the platform, to customize the
// screen appearance in QML accordingly.
#if defined(Q_OS_SYMBIAN)
int platformId = 0;
#elif defined(MEEGO_EDITION_HARMATTAN)
int platformId = 1;
#elif defined(QT_SIMULATOR)
int platformId = 2;
#else
int platformId = 3;
#endif
// Register the Nfc interaction classes to the QML environment
qmlRegisterType<NfcInfo>("Nfc", 1, 0, "NfcInfo");
qmlRegisterType<NfcRecordModel>("Nfc", 1, 0, "NfcRecordModel");
qmlRegisterType<NfcRecordItem>("Nfc", 1, 0, "NfcRecordItem");
qmlRegisterUncreatableType<NfcTypes>("com.nfcinfo.types", 1, 0,
"NfcTypes", "This exports NfcTypes enums to QML");
// Setup QML Viewer
QmlApplicationViewer viewer;
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
viewer.rootContext()->setContextProperty("platform", platformId);
// On MeeGo, only allow activating SNEP if compiled with the library support
// (not permitted otherwise).
bool useSnep = true;
#if defined(MEEGO_EDITION_HARMATTAN) && !defined(USE_SNEP)
useSnep = false;
#endif
viewer.rootContext()->setContextProperty("allowSnep", QVariant(useSnep));
AppSettings* settings = new AppSettings(); // Ownership will be transferred to NfcInfo*
viewer.rootContext()->setContextProperty("settings", settings);
// Symbian has style constants defined in platformStyle, MeeGo has a
// different system.
// To minimize QML code differences between both versions, define
// a customPlatformStyle here, used by both versions.
// (Unfortunately it's not possible to use the original
// "platformStyle" on Symbian and set a "platformStyle" on MeeGo,
// because the Window already has platformStyle property, which
// would have preference over setting a context property from here)
QScopedPointer<QDeclarativePropertyMap> platformStyle(new QDeclarativePropertyMap());
platformStyle->insert("paddingSmall", QVariant(4));
platformStyle->insert("paddingMedium", QVariant(8));
platformStyle->insert("paddingLarge", QVariant(12));
platformStyle->insert("fontSizeSmall", QVariant(18));
platformStyle->insert("colorNormalLight", QVariant(QColor(255, 255, 255)));
platformStyle->insert("colorNormalMid", QVariant(QColor(153, 153, 153)));
#if defined(MEEGO_EDITION_HARMATTAN)
qDebug() << "MeeGo UI platform style";
platformStyle->insert("fontFamilyRegular", QVariant(QString("Nokia Pure Text")));
platformStyle->insert("fontSizeMedium", QVariant(22));
platformStyle->insert("fontHeightMedium", QVariant(getFontHeight(QString("Nokia Pure Text"), 22)));
platformStyle->insert("fontSizeLarge", QVariant(26));
#else
qDebug() << "Symbian UI platform style";
platformStyle->insert("fontFamilyRegular", QVariant(QFont().defaultFamily()));
platformStyle->insert("fontSizeMedium", QVariant(20));
platformStyle->insert("fontHeightMedium", QVariant(getFontHeight(QFont().defaultFamily(), 20)));
platformStyle->insert("fontSizeLarge", QVariant(22));
#endif
viewer.rootContext()->setContextProperty("customPlatformStyle", platformStyle.data());
// Register the image provider class to QML
TagImageCache *tagImageCache = new TagImageCache();
viewer.engine()->addImageProvider(QLatin1String("nfcimageprovider"), tagImageCache);
#ifdef USE_IAP
// In App Purchasing
qDebug() << "Using IAP";
viewer.rootContext()->setContextProperty("useIap", QVariant(true));
#if defined(Q_OS_SYMBIAN)
// In App Purchasing APIs on Symbian
QScopedPointer<IapManager> iapManager(new IapManager());
// Add the known items to the list
// Also retrieves if the user has already purchased the items
// from the internal DB, to prevent the need to go online
// every time.
iapManager->addIapProduct(IAP_ID_ADV_TAGS);
iapManager->addIapProduct(IAP_ID_REMOVE_ADS);
iapManager->addIapProduct(IAP_ID_UNLIMITED);
viewer.rootContext()->setContextProperty("iapManager", iapManager.data());
//.........这里部分代码省略.........
示例13: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
//qDebug()<<QString::fromUtf8("主线程地址是:")<<QThread::currentThread();
#if defined(Q_OS_SYMBIAN)||defined(Q_WS_SIMULATOR)
QPixmap pixmap(":/Image/Symbian.png");
QSplashScreen *splash = new QSplashScreen(pixmap);
splash->show();
splash->raise();
#endif
#ifndef QT_NO_DEBUG
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::HttpProxy);
proxy.setHostName("localhost");
proxy.setPort(8888);
QNetworkProxy::setApplicationProxy(proxy);
#endif
//int width=QApplication::desktop()->width();
//int height=QApplication::desktop()->height();
app->setApplicationName (QString::fromUtf8("IT之家"));
app->setOrganizationName ("Stars");
app->setApplicationVersion ("1.2.2");
Settings *setting=new Settings;
Utility *unility=new Utility;
Cache *cacheContent=new Cache(setting);
//qmlRegisterType<MyXmlListModel>("myXmlListModel",1,0,"MyXmlListModel");
//qmlRegisterType<MyXmlRole>("myXmlListModel", 1, 0, "MyXmlRole");
QmlApplicationViewer viewer;
MyNetworkAccessManagerFactory *network = new MyNetworkAccessManagerFactory();
viewer.engine()->setNetworkAccessManagerFactory(network);
viewer.rootContext ()->setContextProperty ("cacheContent",cacheContent);
viewer.rootContext()->setContextProperty("settings",setting);
viewer.rootContext()->setContextProperty("utility",unility);
QWebSettings::globalSettings ()->setAttribute (QWebSettings::LocalContentCanAccessRemoteUrls,true);
QWebSettings::globalSettings ()->setAttribute (QWebSettings::SpatialNavigationEnabled,true);
QWebSettings::globalSettings ()->setAttribute (QWebSettings::SpatialNavigationEnabled, true);
#if defined(Q_OS_SYMBIAN)||defined(Q_WS_SIMULATOR)
#if defined(Q_OS_S60V5)//判断qt的版本
qWarning("build symbian s60v5");
viewer.setMainQmlFile(QLatin1String("qml/symbian-v5/main.qml"));
if(setting->getValue("night_mode",false).toBool())
unility->setCss("./qml/symbian-v5/theme_black.css",viewer.width()-20);//设置默认的css
else
unility->setCss("./qml/symbian-v5/theme_white.css",viewer.width()-20);
#elif defined(Q_OS_S60V3)
qWarning("build symbian s60v3");
viewer.setMainQmlFile(QLatin1String("qml/symbian-v3/main.qml"));
if(setting->getValue("night_mode",false).toBool())
unility->setCss("./qml/symbian-v3/theme_black.css",viewer.width()-20);//设置默认的css
else
unility->setCss("./qml/symbian-v3/theme_white.css",viewer.width()-20);
#else
qWarning("build symbian anna or simulator");
viewer.setMainQmlFile(QLatin1String("qml/symbian-anna/main.qml"));
if(setting->getValue("night_mode",false).toBool())
unility->setCss("./qml/symbian-anna/theme_black.css",viewer.width()-20);//设置默认的css
else
unility->setCss("./qml/symbian-anna/theme_white.css",viewer.width()-20);
#endif
viewer.showExpanded();
splash->finish(&viewer);
splash->deleteLater();
#elif defined(Q_OS_HARMATTAN)
qWarning("build meego");
viewer.setMainQmlFile(QLatin1String("qml/meego/main.qml"));
if(setting->getValue("night_mode",false).toBool())
unility->setCss("/opt/ithome/qml/meego/theme_black.css",460);//设置默认的css
else
unility->setCss("/opt/ithome/qml/meego/theme_white.css",460);
viewer.showExpanded();
#endif
return app->exec();
}
示例14: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QApplication *app = createApplication(argc, argv);
QmlApplicationViewer viewer;
#if defined(Q_OS_MAEMO)
QPixmap pixmap("/opt/nelisquare/qml/pics/splash-turned.png");
QSplashScreen splash(pixmap);
EventDisabler eventDisabler;
splash.installEventFilter(&eventDisabler);
splash.showFullScreen();
#endif
#if defined(Q_OS_MAEMO)
viewer.addImportPath(QString("/opt/qtm12/imports"));
viewer.engine()->addImportPath(QString("/opt/qtm12/imports"));
viewer.engine()->addPluginPath(QString("/opt/qtm12/plugins"));
#endif
QCoreApplication::addLibraryPath(QString("/opt/nelisquare/plugins"));
viewer.setAttribute(Qt::WA_OpaquePaintEvent);
viewer.setAttribute(Qt::WA_NoSystemBackground);
viewer.viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
viewer.viewport()->setAttribute(Qt::WA_NoSystemBackground);
WindowHelper *windowHelper = new WindowHelper(&viewer);
PictureHelper *pictureHelper = new PictureHelper();
Cache *cache = new Cache();
viewer.rootContext()->setContextProperty("windowHelper", windowHelper);
viewer.rootContext()->setContextProperty("pictureHelper", pictureHelper);
viewer.rootContext()->setContextProperty("cache", cache);
Molome *molome = new Molome();
viewer.rootContext()->setContextProperty("molome", molome);
#if defined(Q_OS_HARMATTAN) || defined(Q_WS_SIMULATOR) || defined(Q_OS_MAEMO)
PlatformUtils platformUtils(app,cache);
viewer.rootContext()->setContextProperty("platformUtils", &platformUtils);
#endif
#if defined(Q_OS_MAEMO)
viewer.installEventFilter(windowHelper);
#elif defined(Q_OS_HARMATTAN)
viewer.installEventFilter(new EventFilter);
#endif
viewer.setMainQmlFile(QLatin1String("qml/main.qml"));
QObject *rootObject = qobject_cast<QObject*>(viewer.rootObject());
#if defined(Q_OS_HARMATTAN) || defined(Q_OS_MAEMO)
new NelisquareDbus(app, &viewer);
#endif
#if defined(Q_OS_MAEMO)
viewer.showFullScreen();
#elif defined(Q_OS_HARMATTAN)
rootObject->connect(molome,SIGNAL(infoUpdated(QVariant,QVariant)),SLOT(onMolomeInfoUpdate(QVariant,QVariant)));
rootObject->connect(molome,SIGNAL(photoRecieved(QVariant,QVariant)),SLOT(onMolomePhoto(QVariant,QVariant)));
viewer.showExpanded();
molome->updateinfo();
#else
viewer.showExpanded();
#endif
rootObject->connect(pictureHelper,SIGNAL(pictureUploaded(QVariant, QVariant)),SLOT(onPictureUploaded(QVariant, QVariant)));
#if defined(Q_OS_MAEMO)
splash.finish(&viewer);
#endif
return app->exec();
}