本文整理汇总了C++中NodeAbstractProperty::reparentHere方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeAbstractProperty::reparentHere方法的具体用法?C++ NodeAbstractProperty::reparentHere怎么用?C++ NodeAbstractProperty::reparentHere使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeAbstractProperty
的用法示例。
在下文中一共展示了NodeAbstractProperty::reparentHere方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createQmlItemNode
QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibraryEntry &itemLibraryEntry, const QPointF &position, NodeAbstractProperty parentproperty)
{
QmlItemNode newQmlItemNode;
try {
RewriterTransaction transaction = view->beginRewriterTransaction(QByteArrayLiteral("QmlItemNode::createQmlItemNode"));
NodeMetaInfo metaInfo = view->model()->metaInfo(itemLibraryEntry.typeName());
int minorVersion = metaInfo.minorVersion();
int majorVersion = metaInfo.majorVersion();
typedef QPair<PropertyName, QString> PropertyBindingEntry;
QList<PropertyBindingEntry> propertyBindingList;
if (itemLibraryEntry.qmlSource().isEmpty()) {
QList<QPair<PropertyName, QVariant> > propertyPairList;
if (!position.isNull()) {
propertyPairList.append(qMakePair(PropertyName("x"), QVariant(qRound(position.x()))));
propertyPairList.append(qMakePair(PropertyName("y"), QVariant(qRound(position.y()))));
}
foreach (const PropertyContainer &property, itemLibraryEntry.properties()) {
if (property.type() == QStringLiteral("binding")) {
propertyBindingList.append(PropertyBindingEntry(property.name(), property.value().toString()));
} else {
propertyPairList.append(qMakePair(property.name(), property.value()));
}
}
newQmlItemNode = QmlItemNode(view->createModelNode(itemLibraryEntry.typeName(), majorVersion, minorVersion, propertyPairList));
} else {
newQmlItemNode = createQmlItemNodeFromSource(view, itemLibraryEntry.qmlSource(), position);
}
if (parentproperty.isValid())
parentproperty.reparentHere(newQmlItemNode);
if (!newQmlItemNode.isValid())
return newQmlItemNode;
newQmlItemNode.setId(view->generateNewId(itemLibraryEntry.name()));
if (!view->currentState().isBaseState()) {
newQmlItemNode.modelNode().variantProperty("opacity").setValue(0);
newQmlItemNode.setVariantProperty("opacity", 1);
}
foreach (const PropertyBindingEntry &propertyBindingEntry, propertyBindingList)
newQmlItemNode.modelNode().bindingProperty(propertyBindingEntry.first).setExpression(propertyBindingEntry.second);
Q_ASSERT(newQmlItemNode.isValid());
}