本文整理汇总了C++中QmlDocument::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ QmlDocument::setParent方法的具体用法?C++ QmlDocument::setParent怎么用?C++ QmlDocument::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QmlDocument
的用法示例。
在下文中一共展示了QmlDocument::setParent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2:
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"));
}
}
}
示例3:
bb::cascades::Container* ScrollControl::createWebViewContainer(QString s) {
QmlDocument *qml = QmlDocument::create("asset:///webview_article.qml").parent(this);
Container *article = qml->createRootObject<Container>();
qml->setParent(article);
return article;
}
示例4: onAboutActionTriggered
void ApplicationUI::onAboutActionTriggered()
{
QmlDocument *qml = QmlDocument::create("asset:///AboutPage.qml").parent(this);
if(qml->hasErrors()) { return; }
Page *aboutPage = qml->createRootObject<Page>();
qml->setParent(aboutPage);
bb::ApplicationInfo appInfo;
aboutPage->setProperty("appName", appInfo.title());
aboutPage->setProperty("versionNumber", appInfo.version());
Sheet *sheet = Sheet::create().content(aboutPage);
connect(aboutPage, SIGNAL(close()), this, SLOT(onSheetPageClosed()));
connect(aboutPage, SIGNAL(openUrl(QString)), this, SLOT(onOpenUrlInBrowser(QString)));
sheet->open();
Application::instance()->setMenuEnabled(false);
}
示例5: createCitiesPage
WeatherGuesserApp::WeatherGuesserApp()
{
// We set up the application Organization and name, this is used by QSettings
// when saving values to the persistent store, in this app the home page is kept in the settings.
QCoreApplication::setOrganizationName("Example");
QCoreApplication::setApplicationName("Weather Guesser");
// Here we create a QMLDocument and load it, we are using build patterns.
QmlDocument *qml = QmlDocument::create().load("main.qml");
qml->setParent(this);
if (!qml->hasErrors()) {
// The application navigationPane is created from QML.
mNavigation = qml->createRootNode<NavigationPane>();
if (mNavigation) {
// Create the cities and weather page, these are pages which is not part of the
// NavigationPane, the application will handle navigation to these.
createCitiesPage();
createWeatherPage();
// Set up the favorite and home page, load models and connects to the appropriate signals.
setUpFavoritesPage();
setUpHomePage();
// Connect to custom signals that will trigger navigation, defined in QML.
Page *continents = mNavigation->findChild<Page*>("continents");
connect(continents, SIGNAL(showContinentCities(QString)), this,
SLOT(onShowContinentCities(QString)));
Page *favorites = mNavigation->findChild<Page*>("favorites");
connect(favorites, SIGNAL(showWeather(QString)), this, SLOT(onShowWeather(QString)));
connect(mContinentCitiesPage, SIGNAL(showWeather(QString)), this,
SLOT(onShowWeather(QString)));
// Finally the main scene for the application is set to NavigationPane.
Application::setScene(mNavigation);
}
}
}
示例6:
AppMeli::AppMeli(bb::cascades::Application *app) :
QObject(app), m_model(new QListDataModel<QObject*>()) {
// 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");
qml->setParent(this);
//mNav = qml->createRootNode<NavigationPane>();
qmlRegisterType<ImageLoader>();
m_model->setParent(this);
qml->setContextProperty("appContext", this);
// create root object for the UI
mNav = qml->createRootObject<NavigationPane>();
// set created root object as a scene
app->setScene(mNav);
}
示例7: setRandomPhoto
bb::cascades::Container* ScrollControl::createImageContainer(QString s) {
QmlDocument *qml = QmlDocument::create("asset:///article.qml").parent(this);
// create root object for the UI
Container *article = qml->createRootObject<Container>();
qml->setParent(article);
ImageView* imageView = article->findChild<ImageView*>("imageView");
int c = setRandomPhoto(imageView);
article->findChild<Label*>("label")->setProperty("text", s);
if (c == 0) {
if (article) {
article->findChild<Label*>("label")->setProperty("text", "Camera folder is empty");
}
}
return article;
}
示例8: addApplicationCover
millionSec::millionSec()
{
// Obtain a QMLDocument and load it into the qml variable, using build patterns.
QmlDocument *qml = QmlDocument::create("asset:///home.qml");
qml->setParent(this);
qml->setContextProperty("home",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);
//calculate();
addApplicationCover();
}
}
}