本文整理汇总了C++中QQmlType::isComposite方法的典型用法代码示例。如果您正苦于以下问题:C++ QQmlType::isComposite方法的具体用法?C++ QQmlType::isComposite怎么用?C++ QQmlType::isComposite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQmlType
的用法示例。
在下文中一共展示了QQmlType::isComposite方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: registrationType
void tst_qqmlmetatype::registrationType()
{
QQmlType *type = QQmlMetaType::qmlType(QString("TestType"), QString("Test"), 1, 0);
QVERIFY(type);
QVERIFY(!type->isInterface());
QVERIFY(!type->isSingleton());
QVERIFY(!type->isComposite());
type = QQmlMetaType::qmlType(QString("TestTypeSingleton"), QString("Test"), 1, 0);
QVERIFY(type);
QVERIFY(!type->isInterface());
QVERIFY(type->isSingleton());
QVERIFY(!type->isComposite());
type = QQmlMetaType::qmlType(QString("TestTypeComposite"), QString("Test"), 1, 0);
QVERIFY(type);
QVERIFY(!type->isInterface());
QVERIFY(!type->isSingleton());
QVERIFY(type->isComposite());
}
示例2: createMetaObject
//.........这里部分代码省略.........
QString changedSigName = stringAt(p->nameIndex) + QLatin1String("Changed");
seenSignals.insert(changedSigName);
cache->appendSignal(changedSigName, flags, effectiveMethodIndex++);
}
}
// Dynamic signals
for (const QmlIR::Signal *s = obj->firstSignal(); s; s = s->next) {
const int paramCount = s->parameters->count;
QList<QByteArray> names;
QVarLengthArray<int, 10> paramTypes(paramCount?(paramCount + 1):0);
if (paramCount) {
paramTypes[0] = paramCount;
QmlIR::SignalParameter *param = s->parameters->first;
for (int i = 0; i < paramCount; ++i, param = param->next) {
names.append(stringAt(param->nameIndex).toUtf8());
if (param->type < builtinTypeCount) {
// built-in type
paramTypes[i + 1] = builtinTypes[param->type].metaType;
} else {
// lazily resolved type
Q_ASSERT(param->type == QV4::CompiledData::Property::Custom);
const QString customTypeName = stringAt(param->customTypeNameIndex);
QQmlType *qmltype = 0;
if (!imports->resolveType(customTypeName, &qmltype, 0, 0, 0)) {
compiler->recordError(s->location, tr("Invalid signal parameter type: %1").arg(customTypeName));
return false;
}
if (qmltype->isComposite()) {
// Composite type usage
qDebug() << "Composite type usage2" << qmltype->sourceUrl() << "Line" << param->location.line << "Col" << param->location.column;
QmlCompilation::TypeReference *typeRef = compiler->findTypeRef(param->customTypeNameIndex);
Q_ASSERT(typeRef->component->compiledData != NULL);
paramTypes[i + 1] = typeRef->component->compiledData->metaTypeId;
} else {
paramTypes[i + 1] = qmltype->typeId();
}
}
}
}
((QQmlVMEMetaData *)dynamicData.data())->signalCount++;
quint32 flags = QQmlPropertyData::IsSignal | QQmlPropertyData::IsFunction |
QQmlPropertyData::IsVMESignal;
if (paramCount)
flags |= QQmlPropertyData::HasArguments;
QString signalName = stringAt(s->nameIndex);
if (seenSignals.contains(signalName)) {
compiler->recordError(s->location, tr("Duplicate signal name: invalid override of property change signal or superclass signal"));
return false;
}
seenSignals.insert(signalName);
cache->appendSignal(signalName, flags, effectiveMethodIndex++,
paramCount?paramTypes.constData():0, names);
}
// Dynamic slots
示例3: tryQualifiedEnumAssignment
bool EnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj, const QQmlPropertyCache *propertyCache, const QQmlPropertyData *prop, QmlIR::Binding *binding)
{
bool isIntProp = (prop->propType == QMetaType::Int) && !prop->isEnum();
if (!prop->isEnum() && !isIntProp)
return true;
if (!prop->isWritable() && !(binding->flags & QV4::CompiledData::Binding::InitializerForReadOnlyDeclaration)) {
compiler->recordError(binding->location, tr("Invalid property assignment: \"%1\" is a read-only property").arg(compiler->stringAt(binding->propertyNameIndex)));
return false;
}
Q_ASSERT(binding->type = QV4::CompiledData::Binding::Type_Script);
const QString string = compiler->bindingAsString(obj, binding->value.compiledScriptIndex);
if (!string.constData()->isUpper())
return true;
int dot = string.indexOf(QLatin1Char('.'));
if (dot == -1 || dot == string.length()-1)
return true;
if (string.indexOf(QLatin1Char('.'), dot+1) != -1)
return true;
QHashedStringRef typeName(string.constData(), dot);
QString enumValue = string.mid(dot+1);
if (isIntProp) {
// Allow enum assignment to ints.
bool ok;
int enumval = evaluateEnum(typeName.toString(), enumValue.toUtf8(), &ok);
if (ok) {
binding->type = QV4::CompiledData::Binding::Type_Number;
binding->value.d = (double)enumval;
binding->flags |= QV4::CompiledData::Binding::IsResolvedEnum;
}
return true;
}
QQmlType *type = 0;
imports->resolveType(typeName, &type, 0, 0, 0);
if (!type && typeName != QLatin1String("Qt"))
return true;
if (type && type->isComposite()) //No enums on composite (or composite singleton) types
return true;
int value = 0;
bool ok = false;
QQmlCompiledData::TypeReference *tr = resolvedTypes->value(obj->inheritedTypeNameIndex);
if (type && tr && tr->type == type) {
QMetaProperty mprop = propertyCache->firstCppMetaObject()->property(prop->coreIndex);
// When these two match, we can short cut the search
if (mprop.isFlagType()) {
value = mprop.enumerator().keysToValue(enumValue.toUtf8().constData(), &ok);
} else {
value = mprop.enumerator().keyToValue(enumValue.toUtf8().constData(), &ok);
}
} else {
// Otherwise we have to search the whole type
if (type) {
value = type->enumValue(QHashedStringRef(enumValue), &ok);
} else {
QByteArray enumName = enumValue.toUtf8();
const QMetaObject *metaObject = StaticQtMetaObject::get();
for (int ii = metaObject->enumeratorCount() - 1; !ok && ii >= 0; --ii) {
QMetaEnum e = metaObject->enumerator(ii);
value = e.keyToValue(enumName.constData(), &ok);
}
}
}
if (!ok)
return true;
binding->type = QV4::CompiledData::Binding::Type_Number;
binding->value.d = (double)value;
binding->flags |= QV4::CompiledData::Binding::IsResolvedEnum;
return true;
}