本文整理汇总了C++中QQmlType::qmlTypeName方法的典型用法代码示例。如果您正苦于以下问题:C++ QQmlType::qmlTypeName方法的具体用法?C++ QQmlType::qmlTypeName怎么用?C++ QQmlType::qmlTypeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQmlType
的用法示例。
在下文中一共展示了QQmlType::qmlTypeName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qmlType
void tst_qqmlmetatype::qmlType()
{
QQmlType *type = QQmlMetaType::qmlType(QString("ParserStatusTestType"), QString("Test"), 1, 0);
QVERIFY(type);
QVERIFY(type->module() == QLatin1String("Test"));
QVERIFY(type->elementName() == QLatin1String("ParserStatusTestType"));
QCOMPARE(type->qmlTypeName(), QLatin1String("Test/ParserStatusTestType"));
type = QQmlMetaType::qmlType("Test/ParserStatusTestType", 1, 0);
QVERIFY(type);
QVERIFY(type->module() == QLatin1String("Test"));
QVERIFY(type->elementName() == QLatin1String("ParserStatusTestType"));
QCOMPARE(type->qmlTypeName(), QLatin1String("Test/ParserStatusTestType"));
}
示例2: addTypeInfo
static void addTypeInfo(QQuickItem *object, TasObject* objectInfo)
{
QString typeName;
QQmlType *type = QQmlMetaType::qmlType(object->metaObject());
if (type) {
typeName = type->qmlTypeName();
int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
if (lastSlash != -1)
typeName = typeName.mid(lastSlash+1);
} else {
typeName = QString::fromUtf8(object->metaObject()->className());
int marker = typeName.indexOf(QLatin1String("_QMLTYPE_"));
if (marker != -1)
typeName = typeName.left(marker);
marker = typeName.indexOf(QLatin1String("_QML_"));
if (marker != -1) {
typeName = typeName.left(marker);
typeName += QLatin1Char('*');
type = QQmlMetaType::qmlType(QMetaType::type(typeName.toLatin1()));
if (type) {
typeName = type->qmlTypeName();
int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
if (lastSlash != -1)
typeName = typeName.mid(lastSlash+1);
}
}
}
if (!typeName.isEmpty()) {
objectInfo->setType(typeName);
}
objectInfo->addAttribute("QML_NATIVE_TYPE", typeName);
QQmlData *ddata = QQmlData::get(object, false);
if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) {
objectInfo->addAttribute("QML_DEFINED_IN_URL", ddata->outerContext->url.toString());
objectInfo->addAttribute("QML_DEFINED_IN_LINE", ddata->lineNumber);
objectInfo->addAttribute("QML_DEFINED_IN_COLUMN", ddata->columnNumber);
}
}
示例3: 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"));
}
示例4: isSubclassOf
bool ServerNodeInstance::isSubclassOf(QObject *object, const QByteArray &superTypeName)
{
if (object == 0)
return false;
const QMetaObject *metaObject = object->metaObject();
while (metaObject) {
QQmlType *qmlType = QQmlMetaType::qmlType(metaObject);
if (qmlType && qmlType->qmlTypeName() == superTypeName) // ignore version numbers
return true;
if (metaObject->className() == superTypeName)
return true;
metaObject = metaObject->superClass();
}
return false;
}
示例5: createTypeMap
bool QmcTypeCompiler::createTypeMap()
{
// qqmltypecompiler.cpp:81
const QHash<int, QmlCompilation::TypeReference> &resolvedTypes = compilation->typeReferences;
for (QHash<int, QmlCompilation::TypeReference>::ConstIterator resolvedType = resolvedTypes.constBegin(), end = resolvedTypes.constEnd();
resolvedType != end; ++resolvedType) {
QScopedPointer<QQmlCompiledData::TypeReference> ref(new QQmlCompiledData::TypeReference);
QQmlType *qmlType = resolvedType->type;
if (resolvedType.value().composite) {
// qqmltypecompiler.cpp:87
if (resolvedType->needsCreation && qmlType->isCompositeSingleton()) {
QQmlError error;
QString reason = tr("Composite Singleton Type %1 is not creatable.").arg(qmlType->qmlTypeName());
error.setDescription(reason);
error.setColumn(resolvedType->location.column);
error.setLine(resolvedType->location.line);
recordError(error);
return false;
}
// qqmltypecompiler.cpp:96
Q_ASSERT(resolvedType->component);
Q_ASSERT(resolvedType->component->compiledData);
ref->component = resolvedType->component->compiledData;
ref->component->addref();
} else if (qmlType) {
ref->type = qmlType;
Q_ASSERT(ref->type);
if (resolvedType->needsCreation && !ref->type->isCreatable()) {
QQmlError error;
QString reason = ref->type->noCreationReason();
if (reason.isEmpty())
reason = tr("Element is not creatable.");
error.setDescription(reason);
error.setColumn(resolvedType->location.column);
error.setLine(resolvedType->location.line);
error.setUrl(compilation->url);
recordError(error);
return false;
}
if (ref->type->containsRevisionedAttributes()) {
QQmlError cacheError;
ref->typePropertyCache = QQmlEnginePrivate::get(compilation->engine)->cache(
ref->type,
resolvedType->minorVersion,
cacheError);
if (!ref->typePropertyCache) {
cacheError.setColumn(resolvedType->location.column);
cacheError.setLine(resolvedType->location.line);
recordError(cacheError);
return false;
}
ref->typePropertyCache->addref();
}
}
ref->majorVersion = resolvedType->majorVersion;
ref->minorVersion = resolvedType->minorVersion;
ref->doDynamicTypeCheck();
compiledData->resolvedTypes.insert(resolvedType.key(), ref.take());
}
return true;
}
示例6: recursiveObjectTest
void tst_QQmlEngineDebugService::recursiveObjectTest(
QObject *o, const QmlDebugObjectReference &oref, bool recursive) const
{
const QMetaObject *meta = o->metaObject();
QQmlType *type = QQmlMetaType::qmlType(meta);
QString className = type ? QString(type->qmlTypeName())
: QString(meta->className());
className = className.mid(className.lastIndexOf(QLatin1Char('/'))+1);
QCOMPARE(oref.debugId, QQmlDebugService::idForObject(o));
QCOMPARE(oref.name, o->objectName());
QCOMPARE(oref.className, className);
QCOMPARE(oref.contextDebugId, QQmlDebugService::idForObject(
qmlContext(o)));
const QObjectList &children = o->children();
for (int i=0; i<children.count(); i++) {
QObject *child = children[i];
if (!qmlContext(child))
continue;
int debugId = QQmlDebugService::idForObject(child);
QVERIFY(debugId >= 0);
QmlDebugObjectReference cref;
foreach (const QmlDebugObjectReference &ref, oref.children) {
if (ref.debugId == debugId) {
cref = ref;
break;
}
}
QVERIFY(cref.debugId >= 0);
if (recursive)
recursiveObjectTest(child, cref, true);
}
foreach (const QmlDebugPropertyReference &p, oref.properties) {
QCOMPARE(p.objectDebugId, QQmlDebugService::idForObject(o));
// signal properties are fake - they are generated from QQmlAbstractBoundSignal children
if (p.name.startsWith("on") && p.name.length() > 2 && p.name[2].isUpper()) {
QString signal = p.value.toString();
QQmlBoundSignalExpression *expr = QQmlPropertyPrivate::signalExpression(QQmlProperty(o, p.name));
QVERIFY(expr && expr->expression() == signal);
QVERIFY(p.valueTypeName.isEmpty());
QVERIFY(p.binding.isEmpty());
QVERIFY(!p.hasNotifySignal);
continue;
}
QMetaProperty pmeta = meta->property(meta->indexOfProperty(p.name.toUtf8().constData()));
QCOMPARE(p.name, QString::fromUtf8(pmeta.name()));
if (pmeta.type() < QVariant::UserType && pmeta.userType() !=
QMetaType::QVariant) // TODO test complex types
QCOMPARE(p.value , pmeta.read(o));
if (p.name == "parent")
QVERIFY(p.valueTypeName == "QGraphicsObject*" ||
p.valueTypeName == "QQuickItem*");
else
QCOMPARE(p.valueTypeName, QString::fromUtf8(pmeta.typeName()));
QQmlAbstractBinding *binding =
QQmlPropertyPrivate::binding(
QQmlProperty(o, p.name));
if (binding)
QCOMPARE(binding->expression(), p.binding);
QCOMPARE(p.hasNotifySignal, pmeta.hasNotifySignal());
QVERIFY(pmeta.isValid());
}
}
示例7: qmlEngine
QQmlInfo::~QQmlInfo()
{
if (0 == --d->ref) {
QList<QQmlError> errors = d->errors;
QQmlEngine *engine = 0;
if (!d->buffer.isEmpty()) {
QQmlError error;
QObject *object = const_cast<QObject *>(d->object);
if (object) {
engine = qmlEngine(d->object);
QString typeName;
QQmlType *type = QQmlMetaType::qmlType(object->metaObject());
if (type) {
typeName = type->qmlTypeName();
int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
if (lastSlash != -1)
typeName = typeName.mid(lastSlash+1);
} else {
typeName = QString::fromUtf8(object->metaObject()->className());
int marker = typeName.indexOf(QLatin1String("_QMLTYPE_"));
if (marker != -1)
typeName = typeName.left(marker);
marker = typeName.indexOf(QLatin1String("_QML_"));
if (marker != -1) {
typeName = typeName.left(marker);
typeName += QLatin1Char('*');
type = QQmlMetaType::qmlType(QMetaType::type(typeName.toLatin1()));
if (type) {
typeName = type->qmlTypeName();
int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
if (lastSlash != -1)
typeName = typeName.mid(lastSlash+1);
}
}
}
d->buffer.prepend(QLatin1String("QML ") + typeName + QLatin1String(": "));
QQmlData *ddata = QQmlData::get(object, false);
if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) {
error.setUrl(ddata->outerContext->url);
error.setLine(ddata->lineNumber);
error.setColumn(ddata->columnNumber);
}
}
error.setDescription(d->buffer);
errors.prepend(error);
}
QQmlEnginePrivate::warning(engine, errors);
delete d;
}
}