当前位置: 首页>>代码示例>>C++>>正文


C++ QDeclarativeView::rootContext方法代码示例

本文整理汇总了C++中QDeclarativeView::rootContext方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeView::rootContext方法的具体用法?C++ QDeclarativeView::rootContext怎么用?C++ QDeclarativeView::rootContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDeclarativeView的用法示例。


在下文中一共展示了QDeclarativeView::rootContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:chegestar,项目名称:butaca,代码行数:53,代码来源:main.cpp

示例2: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QDeclarativeView view;

    view.setSource(QUrl("qrc:/qml/qc_main_from/untitled.qml"));

    srand(time(NULL));
    UiController* uicontr = new UiController(view.rootObject());
    ConnectionController* cc = new ConnectionController(uicontr);

    view.rootContext()->setContextProperty("cc", cc);
    view.rootContext()->setContextProperty("alice", cc->getTransmitterInstance());
    view.rootContext()->setContextProperty("bob", cc->getReceiverInstance());
    view.rootContext()->setContextProperty("eve", cc->getIntercepterInstance());

    //cc->generateKey(100);
    view.show();

    return app.exec();
}
开发者ID:azhi,项目名称:qcrypt,代码行数:21,代码来源:main.cpp

示例3: main

//![0]
int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    QDeclarativeView view;
    MyClass myClass;
    view.rootContext()->setContextProperty("myObject", &myClass);

    view.setSource(QUrl::fromLocalFile("MyItem.qml"));
    view.show();

    return app.exec();
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:13,代码来源:main.cpp

示例4: main

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QDeclarativeView view;
    TadaListEngine tdlEngine(view);

    view.rootContext()->setContextProperty("tdlObject", &tdlEngine);
    tdlEngine.loadView("qml/TadaList/main.qml");

    return app.exec();
}
开发者ID:OlegZiakun,项目名称:Tests,代码行数:12,代码来源:main.cpp

示例5: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

//![0]
QDeclarativeView view;
view.rootContext()->setContextProperty("currentDateTime", QDateTime::currentDateTime());
view.setSource(QUrl::fromLocalFile("MyItem.qml"));
view.show();
//![0]

    return app.exec();
}
开发者ID:Afreeca,项目名称:qt,代码行数:13,代码来源:main.cpp

示例6: main

//![0]
int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    QDeclarativeView view;

    ApplicationData data;
    view.rootContext()->setContextProperty("applicationData", &data);

    view.setSource(QUrl::fromLocalFile("MyItem.qml"));
    view.show();

    return app.exec();
}
开发者ID:RobertoMalatesta,项目名称:emscripten-qt,代码行数:14,代码来源:main.cpp

示例7: QFrame

IconView::IconView(QAbstractItemModel *model, QWidget *parent) :
    QFrame(parent), m_model(model)
{
    QDeclarativeView *view = new QDeclarativeView(this);
    QDeclarativeContext *ctxt = view->rootContext();
    ctxt->setContextProperty("orderModel", m_model);
    ctxt->setContextProperty("sizeData", this);
    view->setSource(QUrl("qrc:IconView.qml"));
    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->setMargin(0);
    mainLayout->addWidget(view);
    setLayout(mainLayout);
}
开发者ID:crysislinux,项目名称:openmenus,代码行数:13,代码来源:iconview.cpp

示例8: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    // Load settings
    QSettings settings;
    settings.setValue("dbtype", "QSQLITE");
    settings.setValue("dbname", "/tmp/testdb.sqlite3");

    // Translator
    QString translationfile = QString("qtmc_nl");
    QTranslator translator;
    if (!translator.load(translationfile) &&
            !translator.load(translationfile,
                             app.applicationDirPath() +  "../lib/qtmc/translations/")) {
        qWarning() << "Failed to load translation file";
    }
    app.installTranslator(&translator);

    // Open database
    QSqlDatabase db = QSqlDatabase::addDatabase(settings.value("dbtype").toString());
    db.setDatabaseName(settings.value("dbname").toString());
    //db.setDatabaseName(":memory:");

    // Check if database is open
    if (!db.open()) {
        qWarning() << app.tr("Cannot open database") << settings.value("dbname");
        return 1;
    }

    // Create mediadb
    MediaDB *mediadb = new MediaDB();
    qDebug() << app.tr("QtMC version") << QString(QTMC_VERSION);
    qDebug() << app.tr("MediaDB version") << mediadb->version();

    // Create qml-view and connect quit-signal
    QDeclarativeView *view = new QDeclarativeView;
    QObject::connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));

    // Expose c++ object to qml
    QDeclarativeContext *ctxt = view->rootContext();
    ctxt->setContextProperty("MediaDB", mediadb);
    ctxt->setContextProperty("Settings", &settings);

    // Run view
    view->setSource(QUrl(app.applicationDirPath() + "/../lib/qtmc/qml/QtMC.qml"));
    view->show();
    //view->showFullScreen();

    return app.exec();
}
开发者ID:Hnz,项目名称:qtmc,代码行数:51,代码来源:main.cpp

示例9: app

int
main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    Controller controller;

    QDeclarativeView view;
    view.rootContext()->setContextProperty("controller", &controller);
    view.setSource(QUrl("qrc:/gui.qml"));
    view.showFullScreen();

    return app.exec();
}
开发者ID:harmattan,项目名称:MeegoSMSBackupRestore,代码行数:14,代码来源:gui.cpp

示例10: main

//![0]
int main(int argc, char ** argv)
{
    QApplication app(argc, argv);

    QDeclarativeView view;

    QDirModel model;
    view.rootContext()->setContextProperty("dirModel", &model);

    view.setSource(QUrl::fromLocalFile("view.qml"));
    view.show();

    return app.exec();
}
开发者ID:sunblithe,项目名称:qt-everywhere-opensource-src-4.7.1,代码行数:15,代码来源:main.cpp

示例11: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QDeclarativeView view;
    QDeclarativeContext *context = view.rootContext();
    context->setContextProperty("backgroundColor",
                                QColor(Qt::yellow));

    view.setSource(QUrl::fromLocalFile("main.qml"));
    view.show();

    return app.exec();
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:14,代码来源:main.cpp

示例12: main

int main(int argc, char **argv)
{
    QApplication app (argc, argv);
    app.setOrganizationName("SfietKonstantin");
    app.setApplicationName("qfb-demo");

    Bridge bridge;

    QDeclarativeView view;
    view.engine()->addImportPath(IMPORT_PATH);
    view.rootContext()->setContextProperty("BRIDGE", &bridge);
    view.setSource(QUrl(MAIN_QML_FILE));
    view.show();

    return app.exec();
}
开发者ID:SfietKonstantin,项目名称:qfb,代码行数:16,代码来源:main.cpp

示例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();
}
开发者ID:frals,项目名称:lpmcustomizer,代码行数:47,代码来源:main.cpp

示例14: main

int main( int argc, char** argv )
{
    QApplication app( argc, argv );
    app.setOrganizationName( "KDE Gluon" );
    app.setApplicationName( "Gluon QML Player" );

    QDeclarativeView view;
    GluonPlayer::Authentication *auth = GluonPlayer::Authentication::instance();
    view.rootContext()->setContextProperty("authentication", auth);
    view.setSource(QUrl("qrc:/main.qml"));
    view.show();

    QObject *obj = view.rootObject();
    QObject *login = obj->findChild<QObject *>("login");
    QObject::connect(auth, SIGNAL(initialized()), login, SLOT(providerSet()));

    return app.exec();
}
开发者ID:cgaebel,项目名称:gluon,代码行数:18,代码来源:main.cpp

示例15: main

int main( int argc, char** argv )
{
	QApplication app( argc, argv );

	Config* config = new Config( &app );

	// If we can't process the command-line or set up the database
	// there's no point continuing
	if ( !processCommandLine() || !setupDatabase() )
		return 0;

	QDeclarativeView view;

	view.connect( view.engine(), SIGNAL(quit()), SLOT(close()) );
	view.setResizeMode( QDeclarativeView::SizeRootObjectToView );

	// Register custom types for access to certail enums from QML
	qmlRegisterType< SoundEngine >( "net.randalflagg.llamaui", 1, 0, "SoundEngine" );
	qmlRegisterType< KeyboardMap >( "net.randalflagg.llamaui", 1, 0, "KeyboardMap" );
	qmlRegisterType< SystemProcess >( "net.randalflagg.llamaui", 1, 0, "SystemProcess" );

	QDeclarativeContext* rootContext = view.rootContext();

	// Initalise the keyboard key/action mapper
	if ( !initKeyboardMap( rootContext ) )
		return 0;

	rootContext->setContextProperty( "config", config );
	initSoundEngine( rootContext );
	initGameMenu( rootContext );
	initEmulatorMenu( rootContext );
	initSystemMenu( rootContext );
	initGameLauncher( rootContext );

	// Create the interface
	QDir dir( Config::instance()->value( "paths", "qmlDir" ).toString() );
	view.setSource( QUrl::fromLocalFile( dir.absoluteFilePath( "main.qml" ) ) );
	view.showFullScreen();

	// Hide the mouse cursor
	app.setOverrideCursor( QCursor( Qt::BlankCursor ) );

	return app.exec();
}
开发者ID:jedillama,项目名称:llamaui,代码行数:44,代码来源:main.cpp


注:本文中的QDeclarativeView::rootContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。