本文整理汇总了C++中QQuickItem::parentItem方法的典型用法代码示例。如果您正苦于以下问题:C++ QQuickItem::parentItem方法的具体用法?C++ QQuickItem::parentItem怎么用?C++ QQuickItem::parentItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQuickItem
的用法示例。
在下文中一共展示了QQuickItem::parentItem方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findGui
void GuiItem::findGui()
{
if (m_gui)
return;
// // Disconnect from an external sender
// QObject *sender = QObject::sender();
// if (sender && this != sender)
// sender->disconnect(this);
// Work up the tree until the next Figure item is found.
QQuickItem *newParent = parentItem();
if (!newParent) return; // Either being deleted or instantiated
GuiBase *guiObj;
while (true) {
guiObj = qobject_cast<GuiBase*>(newParent);
if (guiObj)
break;
if (!newParent->parentItem()) {
connect(newParent, &QQuickItem::parentChanged, this, &GuiItem::findGui);
return;
}
newParent = newParent->parentItem();
}
if (guiObj) {
disconnect(this, &QQuickItem::parentChanged, this, &GuiItem::findGui);
setGui(guiObj);
}
}
示例2: dispatchNavigationEvent
bool Navigation::dispatchNavigationEvent(NavEvent *event)
{
if (event->key() == Navigation::Undefined)
return false;
QObject * receiver = QGuiApplication::focusObject();
while (receiver && !event->isAccepted())
{
// Send to object
QCoreApplication::sendEvent(receiver, event);
if (!event->isAccepted())
{
// Send to attached item
QObject * attachee = qmlAttachedPropertiesObject<Navigation>(receiver, false);
if (attachee)
QCoreApplication::sendEvent(attachee, event);
// Try parent next, visual items if Quick items
QQuickItem * qItem = qobject_cast<QQuickItem *>(receiver);
if (qItem && qItem->parentItem())
receiver = qItem->parentItem();
else
receiver = receiver->parent();
}
}
return event->isAccepted();
}
示例3: setFocus
/* Q_INVOKABLE */ void WWindow::clearFocusItem(QQuickItem * item)
#endif
{
Q_ASSERT(item);
#ifdef QT_4
if (item->focusItem())
{
setFocus(true);
}
#else
Q_D(WWindow);
QQuickItem * parent = d->view->activeFocusItem();
while (parent)
{
parent = parent->parentItem();
if (parent == item)
{
setFocus(true);
return;
}
}
#endif
}
示例4: itemReparented
void QuickItemModel::itemReparented()
{
QQuickItem *item = qobject_cast<QQuickItem*>(sender());
if (!item || item->window() != m_window)
return;
QQuickItem* sourceParent = m_childParentMap.value(item);
Q_ASSERT(sourceParent);
const QModelIndex sourceParentIndex = indexForItem(sourceParent);
QVector<QQuickItem*> &sourceSiblings = m_parentChildMap[sourceParent];
QVector<QQuickItem*>::iterator sit = std::lower_bound(sourceSiblings.begin(), sourceSiblings.end(), item);
Q_ASSERT(sit != sourceSiblings.end() && *sit == item);
const int sourceRow = std::distance(sourceSiblings.begin(), sit);
QQuickItem* destParent = item->parentItem();
Q_ASSERT(destParent);
const QModelIndex destParentIndex = indexForItem(destParent);
QVector<QQuickItem*> &destSiblings = m_parentChildMap[destParent];
QVector<QQuickItem*>::iterator dit = std::lower_bound(destSiblings.begin(), destSiblings.end(), item);
const int destRow = std::distance(destSiblings.begin(), dit);
beginMoveRows(sourceParentIndex, sourceRow, sourceRow, destParentIndex, destRow);
destSiblings.insert(dit, item);
sourceSiblings.erase(sit);
m_childParentMap.insert(item, destParent);
endMoveRows();
}
示例5: objectAdded
void QuickItemModel::objectAdded(QObject* obj)
{
Q_ASSERT(thread() == QThread::currentThread());
QQuickItem *item = qobject_cast<QQuickItem*>(obj);
if (!item)
return;
if (item->window() != m_window)
return; // item for a different scene
if (m_childParentMap.contains(item))
return; // already known
QQuickItem *parentItem = item->parentItem();
if (parentItem) {
// add parent first, if we don't know that yet
if (!m_childParentMap.contains(parentItem))
objectAdded(parentItem);
}
connectItem(item);
const QModelIndex index = indexForItem(parentItem);
Q_ASSERT(index.isValid() || !parentItem);
QVector<QQuickItem*> &children = m_parentChildMap[parentItem];
QVector<QQuickItem*>::iterator it = std::lower_bound(children.begin(), children.end(), obj);
const int row = std::distance(children.begin(), it);
beginInsertRows(index, row, row);
children.insert(it, item);
m_childParentMap.insert(item, parentItem);
endInsertRows();
}
示例6: isClickedOnSoftwareInputPanel
bool MInverseMouseArea::isClickedOnSoftwareInputPanel() const
{
QQuickItem * item = canvas()->activeFocusItem();
while(item != NULL) {
if(item->objectName() == "softwareInputPanel")
return true;
item = item->parentItem();
}
return false;
}
示例7: addAncestorListeners
/*!
\internal
Injects this as a listener to \a item and all its ancestors.
*/
void QQuickScenePosListener::addAncestorListeners(QQuickItem *item)
{
if (item == m_item)
return;
QQuickItem *p = item;
while (p != 0) {
QQuickItemPrivate::get(p)->addItemChangeListener(this, AncestorChangeTypes);
p = p->parentItem();
}
}
示例8: isAncestor
bool QQuickScenePosListener::isAncestor(QQuickItem *item) const
{
if (!m_item)
return false;
QQuickItem *parent = m_item->parentItem();
while (parent) {
if (parent == item)
return true;
parent = parent->parentItem();
}
return false;
}
示例9: disconnect
ColorScope *ColorScope::findParentScope() const
{
QObject *p = 0;
if (m_parent) {
QQuickItem *gp = qobject_cast<QQuickItem *>(m_parent);
if (gp) {
p = gp->parentItem();
} else {
p = m_parent->parent();
}
}
if (!p || !m_parent) {
if (m_parentScope) {
disconnect(m_parentScope.data(), &ColorScope::colorGroupChanged,
this, &ColorScope::colorGroupChanged);
disconnect(m_parentScope.data(), &ColorScope::colorsChanged,
this, &ColorScope::colorsChanged);
}
return 0;
}
ColorScope *c = qobject_cast<ColorScope *>(p);
if (!c) {
c = qmlAttachedProperties(p);
}
if (c != m_parentScope) {
if (m_parentScope) {
disconnect(m_parentScope.data(), &ColorScope::colorGroupChanged,
this, &ColorScope::colorGroupChanged);
disconnect(m_parentScope.data(), &ColorScope::colorsChanged,
this, &ColorScope::colorsChanged);
}
if (c) {
connect(c, &ColorScope::colorGroupChanged,
this, &ColorScope::colorGroupChanged);
connect(c, &ColorScope::colorsChanged,
this, &ColorScope::colorsChanged);
}
//HACK
const_cast<ColorScope *>(this)->m_parentScope = c;
}
return m_parentScope;
}
示例10: addToNewProperty
void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, const QString &newParentProperty)
{
QQmlProperty property(newParent, newParentProperty, context());
if (isList(property)) {
QQmlListReference list = qvariant_cast<QQmlListReference>(property.read());
if (!hasFullImplementedListInterface(list)) {
qWarning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!";
return;
}
list.append(object);
} else if (isObject(property)) {
property.write(objectToVariant(object));
}
QQuickItem *quickItem = qobject_cast<QQuickItem*>(object);
if (object && !(quickItem && quickItem->parentItem()))
object->setParent(newParent);
Q_ASSERT(objectToVariant(object).isValid());
}