本文整理汇总了C++中QQmlType::typeId方法的典型用法代码示例。如果您正苦于以下问题:C++ QQmlType::typeId方法的具体用法?C++ QQmlType::typeId怎么用?C++ QQmlType::typeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQmlType
的用法示例。
在下文中一共展示了QQmlType::typeId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: registerInterface
int registerInterface(const QQmlPrivate::RegisterInterface &interface)
{
if (interface.version > 0)
qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
QWriteLocker lock(metaTypeDataLock());
QQmlMetaTypeData *data = metaTypeData();
int index = data->types.count();
QQmlType *type = new QQmlType(index, interface);
data->types.append(type);
data->idToType.insert(type->typeId(), type);
data->idToType.insert(type->qListTypeId(), type);
// XXX No insertMulti, so no multi-version interfaces?
if (!type->elementName().isEmpty())
data->nameToType.insert(type->elementName(), type);
if (data->interfaces.size() <= interface.typeId)
data->interfaces.resize(interface.typeId + 16);
if (data->lists.size() <= interface.listId)
data->lists.resize(interface.listId + 16);
data->interfaces.setBit(interface.typeId, true);
data->lists.setBit(interface.listId, true);
return index;
}
示例2: listType
/*
Returns the item type for a list of type \a id.
*/
int QQmlMetaType::listType(int id)
{
QReadLocker lock(metaTypeDataLock());
QQmlMetaTypeData *data = metaTypeData();
QQmlType *type = data->idToType.value(id);
if (type && type->qListTypeId() == id)
return type->typeId();
else
return 0;
}
示例3: type
/*!
Returns the type (if any) that corresponds to the QVariant::Type \a userType.
Returns null if no type is registered.
*/
QQmlType *QQmlMetaType::qmlType(int userType)
{
QReadLocker lock(metaTypeDataLock());
QQmlMetaTypeData *data = metaTypeData();
QQmlType *type = data->idToType.value(userType);
if (type && type->typeId() == userType)
return type;
else
return 0;
}
示例4: lock
const char *QQmlMetaType::interfaceIId(int userType)
{
QReadLocker lock(metaTypeDataLock());
QQmlMetaTypeData *data = metaTypeData();
QQmlType *type = data->idToType.value(userType);
lock.unlock();
if (type && type->isInterface() && type->typeId() == userType)
return type->interfaceIId();
else
return 0;
}
示例5: registerType
int registerType(const QQmlPrivate::RegisterType &type)
{
QWriteLocker lock(metaTypeDataLock());
QQmlMetaTypeData *data = metaTypeData();
QString elementName = QString::fromUtf8(type.elementName);
if (!checkRegistration(QQmlType::CppType, data, type.uri, elementName))
return -1;
int index = data->types.count();
QQmlType *dtype = new QQmlType(index, elementName, type);
data->types.append(dtype);
data->idToType.insert(dtype->typeId(), dtype);
if (dtype->qListTypeId()) data->idToType.insert(dtype->qListTypeId(), dtype);
if (!dtype->elementName().isEmpty())
data->nameToType.insertMulti(dtype->elementName(), dtype);
data->metaObjectToType.insertMulti(dtype->baseMetaObject(), dtype);
if (data->objects.size() <= type.typeId)
data->objects.resize(type.typeId + 16);
if (data->lists.size() <= type.listId)
data->lists.resize(type.listId + 16);
data->objects.setBit(type.typeId, true);
if (type.listId) data->lists.setBit(type.listId, true);
if (!dtype->module().isEmpty()) {
const QHashedString &mod = dtype->module();
QQmlMetaTypeData::VersionedUri versionedUri(mod, type.versionMajor);
QQmlTypeModule *module = data->uriToModule.value(versionedUri);
if (!module) {
module = new QQmlTypeModule;
module->d->uri = versionedUri;
data->uriToModule.insert(versionedUri, module);
}
module->d->add(dtype);
}
return index;
}
示例6: createMetaObject
//.........这里部分代码省略.........
// 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
for (const QmlIR::Function *s = obj->firstFunction(); s; s = s->next) {
QQmlJS::AST::FunctionDeclaration *astFunction = s->functionDeclaration;
quint32 flags = QQmlPropertyData::IsFunction | QQmlPropertyData::IsVMEFunction;
if (astFunction->formals)
flags |= QQmlPropertyData::HasArguments;