本文整理汇总了C++中QQmlType::sourceUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ QQmlType::sourceUrl方法的具体用法?C++ QQmlType::sourceUrl怎么用?C++ QQmlType::sourceUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQmlType
的用法示例。
在下文中一共展示了QQmlType::sourceUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compositeType
void tst_qqmlmetatype::compositeType()
{
QQmlEngine engine;
//Loading the test file also loads all composite types it imports
QQmlComponent c(&engine, testFileUrl("testImplicitComposite.qml"));
QObject* obj = c.create();
QVERIFY(obj);
QQmlType *type = QQmlMetaType::qmlType(QString("ImplicitType"), QString(""), 1, 0);
QVERIFY(type);
QVERIFY(type->module() == QLatin1String(""));
QVERIFY(type->elementName() == QLatin1String("ImplicitType"));
QCOMPARE(type->qmlTypeName(), QLatin1String("ImplicitType"));
QCOMPARE(type->sourceUrl(), testFileUrl("ImplicitType.qml"));
}
示例2: createMetaObject
//.........这里部分代码省略.........
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
for (const QmlIR::Function *s = obj->firstFunction(); s; s = s->next) {
QQmlJS::AST::FunctionDeclaration *astFunction = s->functionDeclaration;