本文整理汇总了C++中QDeclarativeView::engine方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeView::engine方法的具体用法?C++ QDeclarativeView::engine怎么用?C++ QDeclarativeView::engine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDeclarativeView
的用法示例。
在下文中一共展示了QDeclarativeView::engine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication::setGraphicsSystem("raster");
QApplication a(argc, argv);
QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
QString privatePathQt(QApplication::applicationDirPath());
QString path(privatePathQt);
path = QDir::toNativeSeparators(path);
Server server;
if (!server.listen(QHostAddress::Any, 6177)) {
std::cerr << "Failed to bind to port" << std::endl;
return 1;
}
QDeclarativeView view;
view.engine()->setOfflineStoragePath(path);
QObject::connect((QObject*)view.engine(), SIGNAL(quit()), &a, SLOT(quit()));
view.setSource(QUrl("qrc:/qml/main.qml"));
view.show();
QString md5;
QString dbname="DemoDB";
QByteArray ba;
ba = QCryptographicHash::hash (dbname.toAscii(), QCryptographicHash::Md5);
md5.append(ba.toHex());
md5.append(".sqlite");
path.append(QDir::separator()).append("Databases");
path.append(QDir::separator()).append(md5);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(path);
if (!db.open()) {
std::cerr << "Cannot open database" << std::endl;
return 1;
}
OrderManager orderManager;
view.rootContext()->setContextProperty("server", &server);
view.rootContext()->setContextProperty("orderManager", &orderManager);
Client client;
QObject::connect(&orderManager, SIGNAL(send()), &client, SLOT(sendOrder()));
QObject::connect(&server, SIGNAL(paied(quint32)), &orderManager, SLOT(payOrder(quint32)));
DeviceManager deviceManager;
QObject::connect(&deviceManager, SIGNAL(registerSignal()), &client, SLOT(sendRegistration()));
view.rootContext()->setContextProperty("deviceManager", &deviceManager);
deviceManager.registerDevice();
return a.exec();
}
示例2: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QApplication *app;
#ifdef QT_SIMULATOR
app = new QApplication(argc, argv);
#else
app = MDeclarativeCache::qApplication(argc, argv);
#endif
app->setApplicationName("Butaca");
app->setOrganizationDomain("com.simonpena");
app->setOrganizationName("simonpena");
// Assume that strings in source files are UTF-8
QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
QString locale(QLocale::system().name());
QTranslator translator;
if (translator.load("l10n/butaca." + locale, ":/")) {
app->installTranslator(&translator);
} else {
translator.load("l10n/butaca.en.qm", ":/");
app->installTranslator(&translator);
}
QDeclarativeView *view;
#ifdef QT_SIMULATOR
view = new QDeclarativeView();
#else
view = MDeclarativeCache::qDeclarativeView();
#endif
view->engine()->setOfflineStoragePath(
QDesktopServices::storageLocation(QDesktopServices::DataLocation));
QDeclarativeContext *context = view->rootContext();
// The Movie Database uses "-" as the divider between language and country code
context->setContextProperty("appLocale", locale.left(locale.indexOf("_")));
Controller *controller = new Controller(context);
view->engine()->setNetworkAccessManagerFactory(new CustomNetworkAccessManagerFactory);
view->setSource(QUrl("qrc:/qml/main.qml"));
view->showFullScreen();
int result = app->exec();
delete controller;
delete view;
delete app;
return result;
}
示例3: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
#ifdef MEEGO_EDITION_HARMATTAN
QApplication *app = MDeclarativeCache::qApplication(argc, argv);
QDeclarativeView *view = MDeclarativeCache::qDeclarativeView();
#else
QApplication *app = new QApplication(argc, argv);
QDeclarativeView *view = new QDeclarativeView();
QDeclarativeView *aboutview = new QDeclarativeView();
#endif
#ifdef Q_WS_MAEMO_5
view->setAttribute(Qt::WA_Maemo5LandscapeOrientation);
view->setAttribute(Qt::WA_Maemo5NonComposited);
view->connect(view->engine(), SIGNAL(quit()), SLOT(close()));
#endif
// For QSettings
QCoreApplication::setOrganizationName("AnttiPohjola");
QCoreApplication::setApplicationName("Nine Men's Morris");
/*
#ifndef Q_WS_MAEMO_5
// Qt 4.7.0 doesn't have qsTrId() support in QML
GConfClient *gconf = gconf_client_get_default();
QString locale = gconf_client_get_string(gconf, "/meegotouch/i18n/region", NULL);
QTranslator translator;
if (translator.load("qmuehle_" + locale, "/usr/share/l10n/meegotouch"))
app->installTranslator(&translator);
else
qDebug() << "Failed to load translation" << ("/usr/share/l10n/meegotouch/qmuehle_" + locale +".qm");
#endif
*/
// Export the Game and Settings classes through the Muehle 1.0 QML module
qmlRegisterType<Game>("Muehle", 1, 0, "Game");
qmlRegisterType<HistoryModel>("Muehle", 1, 0, "HistoryModel");
qmlRegisterType<Settings>("Muehle", 1, 0, "Settings");
view->setSource(QUrl("qrc:/qml/main.qml"));
aboutview->setSource(QUrl("qrc:/qml/AboutPage.qml"));
ViewController* controller = new ViewController(view, aboutview);
//"image://myimageprovider/image.png"
view->engine()->addImageProvider("boardicons", new BoardIconProvider());
// FIXME - for now, don't show fullscreen if screen height >= 800 or width >= 1024
/* QRect screenGeometry=QApplication::desktop()->screenGeometry();
if((screenGeometry.height()<800) && (screenGeometry.width()<1024))
view->showFullScreen();
else view->show();
*/
view->showFullScreen();
return app->exec();
}
示例4: main
int main(int argc, char **argv)
{
qRegisterMetaType<QVector<QFileInfo> >();
qmlRegisterType<DirModel>("FBrowser", 1, 0, "DirModel");
QApplication a(argc, argv);
QDeclarativeView v;
QDeclarativeEngine *e = v.engine();
e->addImageProvider(QLatin1String("nemoThumbnail"), new FileThumbnailImageProvider);
QDeclarativeContext *c = v.rootContext();
c->setContextProperty("fileBrowserUtils", new Utils);
if (QFile::exists("main.qml"))
v.setSource(QUrl::fromLocalFile("main.qml"));
else
v.setSource(QUrl("qrc:/qml/main.qml"));
if (QCoreApplication::arguments().contains("-fullscreen")) {
qDebug() << Q_FUNC_INFO << "Starting in fullscreen mode";
v.showFullScreen();
} else {
qDebug() << Q_FUNC_INFO << "Starting in windowed mode";
v.show();
}
return a.exec();
}
示例5: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDeclarativeView view;
QDeclarativeContext *context = view.rootContext();
context->setContextProperty("backgroundColor",
QColor(Qt::yellow));
KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(view.engine());
kdeclarative.initialize();
//binds things like kconfig and icons
kdeclarative.setupBindings();
//If all gone well, the QScriptEngine has been extracted
QScriptEngine *scriptEngine = kdeclarative.scriptEngine();
Q_ASSERT(scriptEngine);
//Bind a test QObject in the "QtScript way"
QScriptValue global = scriptEngine->globalObject();
TestObject *testObject = new TestObject();
QScriptValue testValue = scriptEngine->newQObject(testObject);
testValue.setScope(global);
global.setProperty("testObject", testValue);
view.setSource(QUrl::fromLocalFile("test.qml"));
view.show();
return app.exec();
}
示例6: QDeclarativeView
MainWindow::MainWindow()
{
QDeclarativeView *view = new QDeclarativeView(this);
view->rootContext()->setContextProperty( "installedGamesModel",
GluonPlayer::GameManager::instance()->installedGamesModel() );
view->rootContext()->setContextProperty( "downloadableGamesModel",
GluonPlayer::GameManager::instance()->downloadableGamesModel() );
view->rootContext()->setContextProperty( "serviceProvider",
GluonPlayer::ServiceProvider::instance() );
view->rootContext()->setContextProperty( "mainWindow",
this );
qmlRegisterType<GluonPlayer::GameMetadata>( "org.kde.gluon.playercomponents", 1, 0, "GameMetadata" );
qmlRegisterType<GluonPlayer::CommentItemsModel>( "org.kde.gluon.playercomponents", 1, 0, "CommentItemsModel" );
qmlRegisterUncreatableType<GluonPlayer::GameItem>( "org.kde.gluon.playercomponents", 1, 0, "GameItem", "To be used only for enums" );
qmlRegisterUncreatableType<GluonPlayer::GameDownloadJob>( "org.kde.gluon.playercomponents", 1, 0, "GameDownloadJob", "Get an instance from serviceProvider" );
m_kdeclarative.setDeclarativeEngine(view->engine());
m_kdeclarative.initialize();
m_kdeclarative.setupBindings();
view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
Plasma::Package *package = new Plasma::Package(QString(), "org.kde.gluon.player", Plasma::PackageStructure::load("Plasma/Generic"));
view->setSource(QUrl(package->filePath("mainscript")));
setCentralWidget(view);
resize(1024, 768);
}
示例7: main
int main(int argc, char **argv)
{
QApplication app(argc, argv);
gst_init(&argc, &argv);
ges_init();
registerTypes();
QDeclarativeView view;
QGLWidget *g = new QGLWidget;
view.setViewport(g);
createGLSurface("timelineSurface", &view);
createGLSurface("editorSurface", &view);
view.setSource(QUrl::fromLocalFile("Timeline.qml"));
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
view.resize(640, 480);
view.show();
if (!QDir::current().exists("media")) {
qDebug () << "Media files missing. Download them by running './download.sh'";
return -1;
}
QObject::connect((QObject*)view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
return app.exec();
}
示例8: main
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QUrl proxyUrl(qgetenv("http_proxy"));
if (proxyUrl.isValid() && !proxyUrl.host().isEmpty()) {
int proxyPort = (proxyUrl.port() > 0) ? proxyUrl.port() : 8080;
QNetworkProxy proxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyPort);
QNetworkProxy::setApplicationProxy(proxy);
}
else {
QNetworkProxyQuery query(QUrl(QLatin1String("http://www.flickr.com")));
QNetworkProxy proxy = QNetworkProxyFactory::systemProxyForQuery(query).value(0);
if (proxy.type() != QNetworkProxy::NoProxy)
QNetworkProxy::setApplicationProxy(proxy);
}
QDeclarativeView view;
view.setSource(QUrl("qrc:/qml/flickr.qml"));
#if defined(FLICKR_FULLSCREEN)
view.window()->showFullScreen();
#else
view.window()->show();
#endif
QObject::connect(view.engine(), SIGNAL(quit()), &view, SLOT(close()));
return app.exec();
}
示例9: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDesktopWidget* desktopWidget = QApplication::desktop();
QRect clientRect = desktopWidget->screenGeometry();
QDeclarativeView view;
QObject *item = (QObject*)view.rootObject();
Model m(item);
view.rootContext()->setContextProperty("appModel", &m);
#if QT_VERSION > 0x040701
view.setAttribute( Qt::WA_LockPortraitOrientation, true);
#endif
view.setSource(QUrl("qrc:/ui.qml"));
view.setSceneRect(clientRect);
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
view.showFullScreen();
QObject::connect((QObject*)view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
QObject::connect(&m, SIGNAL(canQuit()), &app, SLOT(quit()));
QObject::connect(&m, SIGNAL(viewToBeShown()), (QObject*)view.rootObject(), SLOT(qmlviewabouttobeshown()));
m.viewToBeShownNow();
view.show();
return app.exec();
}
示例10: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QApplication app(argc, argv);
InitProduct(argc, argv);
app.setWindowIcon(QIcon("logo.ico"));
QDesktopWidget* desktopWidget = QApplication::desktop();
//获取可用桌面大小
QRect deskRect =desktopWidget->availableGeometry();
//获取设备屏幕大小
//QRect screenRect =desktopWidget->screenGeometry();
DataFilter dataFilter;
QDeclarativeView viewer;
viewer.setWindowFlags(Qt::FramelessWindowHint);
QDeclarativeEngine *engine=viewer.engine();
QDeclarativeContext *context=engine->rootContext();
context->setContextProperty("dataFilter", &dataFilter);
context->setContextProperty("app", &app);
context->setContextProperty("main_window", &viewer);
context->setContextProperty("windowTitle", WindowTitle);
context->setContextProperty("SMF_Product", SMF_Product);
context->setContextProperty("WIDTH", deskRect.width());
context->setContextProperty("HEIGHT", deskRect.height());
viewer.setSource(QUrl("qml/LotNo/main.qml"));
viewer.show();
return app.exec();
}
示例11: main
int main(int argc, char *argv[])
{
QApplication application(argc, argv);
#ifndef Q_OS_SYMBIAN
registerExampleService();
#endif
const QString mainQmlApp = QLatin1String("qrc:/declarative-sfw-dialer.qml");
QDeclarativeView view;
view.setSource(QUrl(mainQmlApp));
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
// Qt.quit() called in embedded .qml by default only emits
// quit() signal, so do this (optionally use Qt.exit()).
QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));
#if defined(Q_OS_SYMBIAN)
view.showFullScreen();
#else // Q_OS_SYMBIAN
view.show();
#endif // Q_OS_SYMBIAN
int ret = application.exec();
#ifndef Q_OS_SYMBIAN
unregisterExampleService();
#endif
return ret;
}
示例12: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDeclarativeView view;
QDeclarativeEngine *engine = view.engine();
AccelerometerReader reader;
engine->rootContext()->setContextProperty("accelerometerReader", &reader);
view.setSource(QUrl("qrc:/Gui.qml"));
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
view.setGeometry(QApplication::desktop()->screenGeometry());
view.showFullScreen();
#else
view.setGeometry((QRect(100, 100, 800, 480)));
view.show();
#endif
return app.exec();
}
示例13: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
qDebug() << "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.";
QApplication *app = MDeclarativeCache::qApplication(argc, argv);
app->setOrganizationName("frals");
app->setOrganizationDomain("frals.se");
app->setApplicationName("lpmcustomizer");
QFont font = QFont("Nokia Pure Text Light");
app->setFont(font);
QDeclarativeView *view = MDeclarativeCache::qDeclarativeView();
QDeclarativeContext *ctx = view->rootContext();
view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
view->setInputMethodHints(Qt::ImhNoPredictiveText);
qmlRegisterType<GalleryItem>("LPM", 1, 0, "GalleryItem");
PlatformIntegration *p = new PlatformIntegration(ctx);
ImageGenerator *ig = new ImageGenerator();
ImageSaver *is = new ImageSaver(ig);
QObject::connect(is, SIGNAL(imageSaved(QString)), p, SLOT(onImageSaved(QString)));
view->engine()->addImageProvider(QString("logocreator"), ig);
ctx->setContextProperty("platform", p);
ctx->setContextProperty("imageSaver", is);
p->updateGallery();
QObject::connect(view->engine(), SIGNAL(quit()), app, SLOT(quit()));
// QString pathInInstallDir = QCoreApplication::applicationDirPath()
// + QLatin1String("/../") + "qml/lpmcustomizer";
view->setSource(QUrl("qrc:/qml/main.qml"));
view->showFullScreen();
// QmlApplicationViewer viewer;
// viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
// viewer.setMainQmlFile(QLatin1String("qml/LPMCustomizer/main.qml"));
// viewer.showExpanded();
return app->exec();
}
示例14: main
int main(int argc, char *argv[])
{
#ifdef Q_OS_SYMBIAN
QApplication::setGraphicsSystem(QLatin1String("openvg"));
#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
QApplication::setGraphicsSystem(QLatin1String("opengl"));
#else
QApplication::setGraphicsSystem(QLatin1String("opengl"));
#endif
QApplication app(argc, argv);
//app.setProperty("NoMStyle", true);
QDeclarativeView viewer;
#ifdef HAVE_GLWIDGET
QGLWidget *glWidget = new QGLWidget(&viewer);
viewer.setViewport(glWidget);
#endif
viewer.setAttribute(Qt::WA_NoSystemBackground);
viewer.setAttribute(Qt::WA_OpaquePaintEvent);
viewer.viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
viewer.viewport()->setAttribute(Qt::WA_NoSystemBackground);
#ifdef Q_WS_MAEMO_5
viewer.engine()->addImportPath(QString("/opt/qtm11/imports"));
viewer.engine()->addPluginPath(QString("/opt/qtm11/plugins"));
#endif
//WindowHelper *windowHelper = new WindowHelper();
AppHelper *appHelper = new AppHelper();
viewer.rootContext()->setContextProperty("helper", appHelper);
//viewer.rootContext()->setContextProperty("windowHelper", windowHelper);
//viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
viewer.setSource(QUrl("qrc:/qml/main.qml"));
#ifdef Q_OS_SYMBIAN
viewer.showFullScreen();
#elif defined(Q_WS_MAEMO_5)
viewer.showFullScreen();
#elif defined(Q_WS_SIMULATOR)
viewer.showFullScreen();
#else
viewer.showFullScreen();
// we don't want full screen on meego tablets at least
//viewer.showMaximized();
#endif
return app.exec();
/*
QDeclarativeView view;
view.setSource(QUrl("qrc:/qml/main.qml"));
view.showFullScreen();
AppHelper *appHelper = new AppHelper();
view.rootContext()->setContextProperty("helper", appHelper);
return app.exec();
*/
}
示例15: main
int main(int argc, char *argv[])
{
#if defined(LUGDULOV_MEEGO)
QCoreApplication::setOrganizationName("net.iksaif.lugdulov");
#else
QCoreApplication::setOrganizationName("Lugdulov");
#endif
QCoreApplication::setApplicationName("Lugdulov");
QCoreApplication::setApplicationVersion(LUGDULOV_VERSION);
#ifdef HAVE_MEEGOTOUCH
QApplication *app = MDeclarativeCache::qApplication(argc, argv);
#else
QApplication application(argc, argv);
QApplication *app = &application;
#endif
init_translations();
init_libraries();
Settings *settings = Settings::settings();
PluginsModel *plugins = PluginsModel();
qmlRegisterUncreatableType<Settings>("net.iksaif.lugdulov", 1, 0, "Settings");
qmlRegisterUncreatableType<PluginsModel>("net.iksaif.lugdulov", 1, 0, "PluginsModel", "This object is created in the model.");
qmlRegisterUncreatableType<StationsModel>("net.iksaif.lugdulov", 1, 0, "StationsModel", "This object is created in the model.");
qmlRegisterUncreatableType<StationsSortFilterProxyModel>("net.iksaif.lugdulov", 1, 0, "StationsSortFilterModel", "This object is created in the model.");
#ifdef HAVE_MEEGOTOUCH
QDeclarativeView *view = MDeclarativeCache::qDeclarativeView();
#else
QDeclarativeView *view = new QDeclarativeView();
#endif
QObject::connect(view->engine(), SIGNAL(quit()), app, SLOT(quit()));
view->rootContext()->setContextProperty("plugins", plugins);
view->rootContext()->setContextProperty("settings", settings);
#ifdef LUGDULOV_PLATFORM_HARMATTAN
view->setSource(QUrl("qrc:/qml/harmattan/main.qml"));
view->showFullScreen();
#elif defined(Q_OS_SYMBIAN)
view->setSource(QUrl("qrc:/qml/symbian/main.qml"));
view->showFullScreen();
#else
view->setSource(QUrl("qrc:/qml/generic/main.qml"));
view->show();
#endif
int result = app->exec();
delete view;
delete app;
return result;
}