本文整理汇总了C++中QQmlContext::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ QQmlContext::setParent方法的具体用法?C++ QQmlContext::setParent怎么用?C++ QQmlContext::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQmlContext
的用法示例。
在下文中一共展示了QQmlContext::setParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: page
WebPageActivationData WebPages::page(int tabId, int parentId)
{
if (!m_webPageComponent) {
qWarning() << "TabModel not initialized!";
return WebPageActivationData(0, false);
}
if (m_activePage && m_activePage->webPage && m_activePage->webPage->tabId() == tabId) {
m_activePage->webPage->resumeView();
m_activePage->webPage->setVisible(true);
return WebPageActivationData(m_activePage->webPage, false);
}
#ifdef DEBUG_LOGS
qDebug() << "about to create a new tab or activate old:" << tabId;
#endif
WebPageEntry *pageEntry = m_activePages.value(tabId, 0);
bool resurrect = pageEntry && !pageEntry->webPage;
if (!pageEntry || resurrect) {
QQmlContext *creationContext = m_webPageComponent->creationContext();
QQmlContext *context = new QQmlContext(creationContext ? creationContext : QQmlEngine::contextForObject(m_webContainer));
QObject *object = m_webPageComponent->beginCreate(context);
if (object) {
context->setParent(object);
object->setParent(m_webContainer);
DeclarativeWebPage *webPage = qobject_cast<DeclarativeWebPage *>(object);
if (webPage) {
webPage->setParentItem(m_webContainer);
webPage->setParentID(parentId);
webPage->setTabId(tabId);
webPage->setContainer(m_webContainer);
if (!pageEntry) {
pageEntry = new WebPageEntry(webPage, 0);
} else {
pageEntry->webPage = webPage;
}
m_webPageComponent->completeCreate();
#ifdef DEBUG_LOGS
qDebug() << "New view id:" << webPage->uniqueID() << "parentId:" << webPage->parentId() << "tab id:" << webPage->tabId();
#endif
m_activePages.insert(tabId, pageEntry);
++m_count;
} else {
qmlInfo(m_webContainer) << "webPage component must be a WebPage component";
}
} else {
qmlInfo(m_webContainer) << "Creation of the web page failed. Error: " << m_webPageComponent->errorString();
delete object;
object = 0;
}
}
updateActivePage(pageEntry, resurrect);
#ifdef DEBUG_LOGS
dumpPages();
#endif
return WebPageActivationData(pageEntry->webPage, true);
}