本文整理汇总了C++中QmlItemNode::defaultPropertyName方法的典型用法代码示例。如果您正苦于以下问题:C++ QmlItemNode::defaultPropertyName方法的具体用法?C++ QmlItemNode::defaultPropertyName怎么用?C++ QmlItemNode::defaultPropertyName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QmlItemNode
的用法示例。
在下文中一共展示了QmlItemNode::defaultPropertyName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createQmlItemNode
QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibraryEntry &itemLibraryEntry, const QPointF &position, QmlItemNode parentQmlItemNode)
{
if (!parentQmlItemNode.isValid())
parentQmlItemNode = QmlItemNode(view->rootModelNode());
Q_ASSERT(parentQmlItemNode.isValid());
QmlItemNode newQmlItemNode;
try {
RewriterTransaction transaction = view->beginRewriterTransaction();
NodeMetaInfo metaInfo = view->model()->metaInfo(itemLibraryEntry.typeName());
int minorVersion = metaInfo.minorVersion();
int majorVersion = metaInfo.majorVersion();
if (itemLibraryEntry.typeName().contains('.')) {
const QString newImportUrl = itemLibraryEntry.requiredImport();
if (!itemLibraryEntry.requiredImport().isEmpty()) {
const QString newImportVersion = QString("%1.%2").arg(QString::number(itemLibraryEntry.majorVersion()), QString::number(itemLibraryEntry.minorVersion()));
Import newImport = Import::createLibraryImport(newImportUrl, newImportVersion);
if (itemLibraryEntry.majorVersion() == -1 && itemLibraryEntry.minorVersion() == -1)
newImport = Import::createFileImport(newImportUrl, QString());
else
newImport = Import::createLibraryImport(newImportUrl, newImportVersion);
foreach (const Import &import, view->model()->imports()) {
if (import.isLibraryImport()
&& import.url() == newImport.url()
&& import.version() == newImport.version()) {
// reuse this import
newImport = import;
break;
}
}
if (!view->model()->hasImport(newImport, true, true))
view->model()->changeImports(QList<Import>() << newImport, QList<Import>());
}
}
if (itemLibraryEntry.qmlSource().isEmpty()) {
QList<QPair<PropertyName, QVariant> > propertyPairList;
propertyPairList.append(qMakePair(PropertyName("x"), QVariant(qRound(position.x()))));
propertyPairList.append(qMakePair(PropertyName("y"), QVariant(qRound(position.y()))));
foreach (const PropertyContainer &property, itemLibraryEntry.properties())
propertyPairList.append(qMakePair(property.name(), property.value()));
newQmlItemNode = QmlItemNode(view->createModelNode(itemLibraryEntry.typeName(), majorVersion, minorVersion, propertyPairList));
} else {
newQmlItemNode = createQmlItemNodeFromSource(view, itemLibraryEntry.qmlSource(), position);
}
if (parentQmlItemNode.hasDefaultPropertyName())
parentQmlItemNode.nodeAbstractProperty(parentQmlItemNode.defaultPropertyName()).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);
}
Q_ASSERT(newQmlItemNode.isValid());
}