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


C++ QmlDocument类代码示例

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


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

示例1: QObject

ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
		QObject(app) {
	// create scene document from main.qml asset
	// set parent to created document to ensure it exists for the whole application lifetime
	QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

	// Expose this class to QML such that our Q_INVOKABLE methods defined in applicationui.hpp
	// can be called from our QML classes.
	qml->setContextProperty("cpp", this);

	// create root object for the UI
	AbstractPane *root = qml->createRootObject<AbstractPane>();
	// set created root object as a scene
	app->setScene(root);

	// The code from here down to "void ApplicationUI::logEvent" is used to determine the device
	// location and log the result to the Flurry server. Any errors in the process will also be
	// logged
	QGeoPositionInfoSource *source =
			QGeoPositionInfoSource::createDefaultSource(this);

	if (source) {
		bool positionUpdatedConnected = connect(source,
				SIGNAL(positionUpdated (const QGeoPositionInfo &)), this,
				SLOT(positionUpdated (const QGeoPositionInfo &)));

		if (positionUpdatedConnected) {
			source->requestUpdate();
		} else {
			qDebug() << "positionUpdated connection failed";
			Flurry::Analytics::LogError("positionUpdated connection failed");
		}
	} else {
开发者ID:26filip,项目名称:Cascades-Community-Samples,代码行数:33,代码来源:applicationui.cpp

示例2: setUpStampListModel

StampCollectorApp::StampCollectorApp()
{
    // The entire UI is a drill down list, which means that when an item is selected
    // a navigation takes place to a Content View with a large stamp image and a descriptive text.
    // The main.qml contain the navigation pane and the first page (the list).
    QmlDocument *qml = QmlDocument::create().load("main.qml");
    qml->setParent(this);
    mNav = qml->createRootNode<NavigationPane>();

    // We get the ListView from QML, so that we can connect to the selctionChange signal and set
    // up a DataModel for JSON data.
    ListView *stampList = mNav->findChild<ListView*>("stampList");
    setUpStampListModel(stampList);
    QObject::connect(stampList, SIGNAL(selectionChanged(const QVariantList, bool)), this,
            SLOT(onSelectionChanged(const QVariantList, bool)));

    // The second page, with a detailed description and large stamp image is set up in QML
    // Navigation to this page is handled in the onSelectionChanged Slot function.
    QmlDocument *contentQml = QmlDocument::create().load("ContentPage.qml");
    contentQml->setParent(this);
    mQmlContext = contentQml->documentContext();

    // Set up a context property to the navigation pane so that it is possible to navigate back to the list
    // and create the content page.
    mQmlContext->setContextProperty("_nav", mNav);
    mContentPage = contentQml->createRootNode<Page>();

    // Create the application scene and we are done.
    Application::setScene(mNav);
}
开发者ID:drkillinger,项目名称:Cascades-Samples,代码行数:30,代码来源:stampcollectorapp.cpp

示例3: QObject

ApplicationUI::ApplicationUI(bb::cascades::Application *app)
	: QObject(app)
{
	ThemeSupport* themeSupport = app->themeSupport();
	Theme* currentTheme = themeSupport->theme();
	ColorTheme* colorTheme = currentTheme->colorTheme();
	VisualStyle::Type style = colorTheme->style();
	switch (style)
	{
	case VisualStyle::Bright:
		m_theme = Bright;
		break;
	case VisualStyle::Dark:
		m_theme = Dark;
		break;
	}
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
	qml->setContextProperty("_native", this);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    // set created root object as a scene
    app->setScene(root);
}
开发者ID:knobtviker,项目名称:ThemeSetter,代码行数:26,代码来源:applicationui.cpp

示例4: start

HelloForeignWindowApp::HelloForeignWindowApp()
{
    mTvOn = false;
    mTvInitialized = false;

    // Here we create a QMLDocument and load the main UI QML file.
    QmlDocument *qml = QmlDocument::create().load("helloforeignwindow.qml");

    if (!qml->hasErrors()) {

        // Set a context property for the QML to the application object, so that we
        // can call invokable functions in the app from QML.
        qml->setContextProperty("foreignWindowApp", this);

        // The application Page is created from QML.
        mAppPage = qml->createRootNode<Page>();

        if (mAppPage) {

            Application::setScene(mAppPage);

            // Start the thread in which we render to the custom window.
            start();
        }
    }
}
开发者ID:PaulBernhardt,项目名称:Cascades-Samples,代码行数:26,代码来源:helloforeignwindowapp.cpp

示例5: QObject

//! [0]
App::App(QObject *parent)
    : QObject(parent)
    , m_targetType(0)
    , m_action(QLatin1String("bb.action.OPEN"))
    , m_mimeType(QLatin1String("image/png"))
    , m_model(new GroupDataModel(this))
    , m_invokeManager(new InvokeManager(this))
    , m_dialog(new SystemDialog(this))
{
    // Disable item grouping in the targets result list
    m_model->setGrouping(ItemGrouping::None);

    // Create signal/slot connections to handle card status changes
    bool ok = connect(m_invokeManager,
                      SIGNAL(childCardDone(const bb::system::CardDoneMessage&)), this,
                      SLOT(childCardDone(const bb::system::CardDoneMessage&)));
    Q_ASSERT(ok);
    ok = connect(m_invokeManager, SIGNAL(peekStarted(bb::system::CardPeek::Type)),
                 this, SLOT(peekStarted(bb::system::CardPeek::Type)));
    Q_ASSERT(ok);
    ok = connect(m_invokeManager, SIGNAL(peekEnded()), this, SLOT(peekEnded()));
    Q_ASSERT(ok);

    // Load the UI from the QML file
    QmlDocument *qml = QmlDocument::create("asset:///main.qml");
    qml->setContextProperty("_app", this);

    AbstractPane *root = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(root);
}
开发者ID:AnujAroshA,项目名称:Cascades-Samples,代码行数:31,代码来源:app.cpp

示例6: QObject

ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
        				QObject(app)
{
	// prepare the localization
	m_pTranslator = new QTranslator(this);
	m_pLocaleHandler = new LocaleHandler(this);
	if(!QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()))) {
		// This is an abnormal situation! Something went wrong!
		// Add own code to recover here
		qWarning() << "Recovering from a failed connect()";
	}
	// initial load
	onSystemLanguageChanged();

	// Create scene document from main.qml asset, the parent is set
	// to ensure the document gets destroyed properly at shut down.
	QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

	qml->setContextProperty("app", this);

	// Create root object for the UI
	AbstractPane *root = qml->createRootObject<AbstractPane>();

	// Set created root object as the application scene
	app->setScene(root);

	// set status message of the button
	//this->setStatus(QString("Next bus information here"));

	//set a value of a component in QML from CPP
	//root->setProperty("tempText", "Hello World...");

}
开发者ID:jnbagale,项目名称:uwlshuttleapp,代码行数:33,代码来源:applicationui.cpp

示例7: QObject

ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
        QObject(app)
{
    // prepare the localization
    m_pTranslator = new QTranslator(this);
    m_pLocaleHandler = new LocaleHandler(this);

    qmlRegisterType< MyModel >("MyModel", 1, 0, "MyModel");

    bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()));
    // This is only available in Debug builds
    Q_ASSERT(res);
    // Since the variable is not used in the app, this is added to avoid a
    // compiler warning
    Q_UNUSED(res);

    // initial load
    onSystemLanguageChanged();

    // Create scene document from main.qml asset, the parent is set
    // to ensure the document gets destroyed properly at shut down.
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("Application", this);

    // Create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    // Set created root object as the application scene
    app->setScene(root);
}
开发者ID:FreakyTeddy,项目名称:QSharedPointer-QObject,代码行数:30,代码来源:applicationui.cpp

示例8: QObject

//! [0]
App::App(QObject *parent)
    : QObject(parent)
    , m_invokeManager(new InvokeManager(this))
    , m_backButtonVisible(false)
{
    // Listen to incoming invocation requests
    connect(m_invokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)), this, SLOT(handleInvoke(const bb::system::InvokeRequest&)));
    connect(m_invokeManager, SIGNAL(cardResizeRequested(const bb::system::CardResizeMessage&)), this, SLOT(resized(const bb::system::CardResizeMessage&)));
    connect(m_invokeManager, SIGNAL(cardPooled(const bb::system::CardDoneMessage&)), this, SLOT(pooled(const bb::system::CardDoneMessage&)));

    // Initialize properties with default values
    switch (m_invokeManager->startupMode()) {
        case ApplicationStartupMode::LaunchApplication:
            m_startupMode = tr("Launch");
            break;
        case ApplicationStartupMode::InvokeApplication:
            m_startupMode = tr("Invoke");
            break;
        case ApplicationStartupMode::InvokeCard:
            m_startupMode = tr("Card");
            break;
    }

    m_source = m_target = m_action = m_mimeType = m_uri = m_data = m_status = tr("--");
    m_title = tr("InvokeClient");

    // Create the UI
    QmlDocument *qml = QmlDocument::create("asset:///main.qml");
    qml->setContextProperty("_app", this);
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(root);
}
开发者ID:Ataya09,项目名称:Cascades-Samples,代码行数:33,代码来源:app.cpp

示例9: QObject

ApplicationUI::ApplicationUI() :
        QObject(),
        m_translator(new QTranslator(this)),
        m_localeHandler(new LocaleHandler(this)),
        m_invokeManager(new InvokeManager(this))
{
    // prepare the localization
    if (!QObject::connect(m_localeHandler, SIGNAL(systemLanguageChanged()),
            this, SLOT(onSystemLanguageChanged()))) {
        // This is an abnormal situation! Something went wrong!
        // Add own code to recover here
        qWarning() << "Recovering from a failed connect()";
    }

    // initial load
    onSystemLanguageChanged();

    // Create scene document from main.qml asset, the parent is set
    // to ensure the document gets destroyed properly at shut down.
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    // Make app available to the qml.
    qml->setContextProperty("app", this);

    // Create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    // Set created root object as the application scene
    Application::instance()->setScene(root);
}
开发者ID:CurtisLee,项目名称:Cascades-Community-Samples,代码行数:30,代码来源:applicationui.cpp

示例10: createCitiesPage

void WeatherGuesserApp::createCitiesPage()
{
    QmlDocument *qml = QmlDocument::create().load("ContinentCitiesPage.qml");

    if (!qml->hasErrors()) {

        mContinentCitiesPage = qml->createRootNode<Page>();

        if (mContinentCitiesPage) {

            // Set up a cities model for the page, this model will load different cities depending
            // on which continent is selected.
            ListView *citiesList = mContinentCitiesPage->findChild<ListView*>("citiesList");
            CityModel *cityModel = new CityModel(QStringList() << "name", "continents_connection",
                    this);
            citiesList->setDataModel(cityModel);

            // Connect to the continents page custom signal.
            Page *continents = mNavigation->findChild<Page*>("continents");
            connect(continents, SIGNAL(showContinentCities(QString)), cityModel,
                    SLOT(onChangeContinent(QString)));

            qml->documentContext()->setContextProperty("_navigation", mNavigation);
        }
    }
}
开发者ID:PaulBernhardt,项目名称:Cascades-Samples,代码行数:26,代码来源:weatherguesserapp.cpp

示例11: createWeatherPage

void WeatherGuesserApp::createWeatherPage()
{
    QmlDocument *qml = QmlDocument::create().load("WeatherPage.qml");

    if (!qml->hasErrors()) {

        mWeatherPage = qml->createRootNode<Page>();

        if (mWeatherPage) {

            // Set up a weather model the list, the model will load weather data
            ListView *weatherList = mWeatherPage->findChild<ListView*>("weatherList");
            WeatherModel *weatherModel = new WeatherModel(this);
            weatherList->setDataModel(weatherModel);

            // Connect the weather model to page signals that updates city for which model should be shown.
            connect(mContinentCitiesPage, SIGNAL(showWeather(QString)), weatherModel,
                    SLOT(onUpdateWeatherCity(QString)));

            Page *favorites = mNavigation->findChild<Page*>("favorites");
            connect(favorites, SIGNAL(showWeather(QString)), weatherModel,
                    SLOT(onUpdateWeatherCity(QString)));

            qml->documentContext()->setContextProperty("_navigation", mNavigation);
        }
    }
}
开发者ID:PaulBernhardt,项目名称:Cascades-Samples,代码行数:27,代码来源:weatherguesserapp.cpp

示例12:

millionSec::millionSec()
{
    // Obtain a QMLDocument and load it into the qml variable, using build patterns.
    QmlDocument *qml = QmlDocument::create("asset:///second.qml");
    qml->setParent(this);
    NavigationPane *nav = qml->createRootObject<NavigationPane>();

    // If the QML document is valid, we process it.
    if (!qml->hasErrors()) {

        // Create the application Page from QMLDocument.
        //Page *appPage = qml->createRootObject<Page>();

        if (nav) {
            // Set the main scene for the application to the Page.
            Application::instance()->setScene(nav);
            DropDown *day = DropDown::create();
            int date = day->selectedIndex();

            DropDown *month = DropDown::create();
            month->add(Option::create().text("Jan"));
            month->add(Option::create().text("Feb"));
        }
    }
}
开发者ID:cdonthini,项目名称:MillionthSec,代码行数:25,代码来源:millionSec.cpp

示例13: main

Q_DECL_EXPORT int main(int argc, char **argv)
{
//! [0]
    // Register our custom types with QML, so that they can be used as property types
    qmlRegisterUncreatableType<EventEditor>("com.example.bb10samples.pim.calendar", 1, 0, "EventEditor", "Usage as property type and access to enums");
    qmlRegisterType<EventViewer>();
//! [0]

    Application app(argc, argv);

    // localization support
    QTranslator translator;
    const QString locale_string = QLocale().name();
    const QString filename = QString::fromLatin1("calendar_%1").arg(locale_string);
    if (translator.load(filename, "app/native/qm")) {
        app.installTranslator(&translator);
    }

//! [1]
    // Load the UI description from main.qml
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(&app);

    // Make the Calendar object available to the UI as context property
    qml->setContextProperty("_calendar", new Calendar(&app));
//! [1]

    // Create the application scene
    AbstractPane *appPage = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(appPage);

    return Application::exec();
}
开发者ID:AlessioCampanelli,项目名称:Cascades-Samples,代码行数:32,代码来源:main.cpp

示例14: QObject

ApplicationUI::ApplicationUI(bb::cascades::Application *app) : QObject(app)
{
    qRegisterMetaType<GroupDataModel*>("GroupDataModel*");

    qmlRegisterType<ViewState>("enums", 1, 0, "ViewState");

    TicTacService *service = new TicTacService(this);
    service->connectToHost(QHostAddress("192.168.0.247"), 1337);

    LoginViewModel* loginVM = new LoginViewModel(service, this);
    MainViewModel* mainVM = new MainViewModel(service, this);

    // prepare the localization
    m_pTranslator = new QTranslator(this);
    m_pLocaleHandler = new LocaleHandler(this);
    if(!QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()))) {
        // This is an abnormal situation! Something went wrong!
        // Add own code to recover here
        qWarning() << "Recovering from a failed connect()";
    }
    // initial load
    onSystemLanguageChanged();

    // Create scene document from main.qml asset, the parent is set
    // to ensure the document gets destroyed properly at shut down.
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("mainVM", mainVM);
    qml->setContextProperty("loginVM", loginVM);

    // Create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();

    // Set created root object as the application scene
    app->setScene(root);
}
开发者ID:SamVerschueren,项目名称:bbTicTacTen,代码行数:35,代码来源:applicationui.cpp

示例15: setNumMoves

KakelApp::KakelApp()
{

  // Create and Load the QMLDocument, using build patterns.
  QmlDocument *qml = QmlDocument::create("asset:///main.qml");

  if (!qml->hasErrors()) {

    setNumMoves(0);
    mNumTiles = 4;

    // Set the context property we want to use from inside the QML file. Functions exposed
    // via Q_INVOKABLE will be found with the property and the name of the function.
    qml->setContextProperty("kakel", this);

    // The application Page is created from the QML file.
    mAppPage = qml->createRootObject<Page>();

    findPlayAreaAndInitialize(mAppPage);

    if (mAppPage) {
      // Finally the main scene for the application is set to the Page.
      Application::instance()->setScene(mAppPage);
    }
  }
}
开发者ID:Angtrim,项目名称:Cascades-Samples,代码行数:26,代码来源:kakelapp.cpp


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