当前位置: 首页>>代码示例>>C++>>正文


C++ QMetaMethod::enclosingMetaObject方法代码示例

本文整理汇总了C++中QMetaMethod::enclosingMetaObject方法的典型用法代码示例。如果您正苦于以下问题:C++ QMetaMethod::enclosingMetaObject方法的具体用法?C++ QMetaMethod::enclosingMetaObject怎么用?C++ QMetaMethod::enclosingMetaObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMetaMethod的用法示例。


在下文中一共展示了QMetaMethod::enclosingMetaObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: comparisonOperators

void tst_QMetaMethod::comparisonOperators()
{
    static const QMetaObject *mo = &MethodTestObject::staticMetaObject;
    for (int x = 0; x < 2; ++x) {
        int count = x ? mo->constructorCount() : mo->methodCount();
        for (int i = 0; i < count; ++i) {
            QMetaMethod method = x ? mo->constructor(i) : mo->method(i);
            const QMetaObject *methodMo = method.enclosingMetaObject();
            for (int j = 0; j < count; ++j) {
                QMetaMethod other = x ? mo->constructor(j) : mo->method(j);
                bool expectedEqual = ((methodMo == other.enclosingMetaObject())
                                      && (i == j));
                QCOMPARE(method == other, expectedEqual);
                QCOMPARE(method != other, !expectedEqual);
                QCOMPARE(other == method, expectedEqual);
                QCOMPARE(other != method, !expectedEqual);
            }

            QVERIFY(method != QMetaMethod());
            QVERIFY(QMetaMethod() != method);
            QVERIFY(!(method == QMetaMethod()));
            QVERIFY(!(QMetaMethod() == method));
        }
    }

    // Constructors and normal methods with identical index should not
    // compare equal
    for (int i = 0; i < qMin(mo->methodCount(), mo->constructorCount()); ++i) {
        QMetaMethod method = mo->method(i);
        QMetaMethod constructor = mo->constructor(i);
        QVERIFY(method != constructor);
        QVERIFY(!(method == constructor));
    }
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:34,代码来源:tst_qmetamethod.cpp

示例2:

factory_method::factory_method(type result_type, QMetaMethod meta_method) :
	_object_type{meta_method.enclosingMetaObject()},
	_result_type{std::move(result_type)},
	_meta_method{std::move(meta_method)}
{
	assert(meta_method.methodType() == QMetaMethod::Method || meta_method.methodType() == QMetaMethod::Slot);
	assert(meta_method.parameterCount() == 0);
	assert(meta_method.enclosingMetaObject() != nullptr);
	assert(!_result_type.is_empty());
	assert(_result_type.name() + "*" == std::string{meta_method.typeName()});
}
开发者ID:respu,项目名称:injeqt,代码行数:11,代码来源:factory-method.cpp

示例3: create

QDeclarativePropertyCache::Data QDeclarativePropertyCache::create(const QMetaObject *metaObject, 
                                                                  const QString &property)
{
    Q_ASSERT(metaObject);

    QDeclarativePropertyCache::Data rv;
    {
        const QMetaObject *cmo = metaObject;
        while (cmo) {
            int idx = metaObject->indexOfProperty(property.toUtf8());
            if (idx != -1) {
                QMetaProperty p = metaObject->property(idx);
                if (p.isScriptable()) {
                    rv.load(metaObject->property(idx));
                    if (!isDynamicMetaObject(cmo))
                        rv.flags |= Data::IsDirect;
                    return rv;
                } else {
                    while (cmo && cmo->propertyOffset() >= idx)
                        cmo = cmo->superClass();
                }
            } else {
                cmo = 0;
            }
        }
    }

    int methodCount = metaObject->methodCount();
    for (int ii = methodCount - 1; ii >= 3; --ii) { // >=3 to block the destroyed signal and deleteLater() slot
        QMetaMethod m = metaObject->method(ii);
        if (m.access() == QMetaMethod::Private)
            continue;
        QString methodName = QString::fromUtf8(m.signature());

        int parenIdx = methodName.indexOf(QLatin1Char('('));
        Q_ASSERT(parenIdx != -1);
        QStringRef methodNameRef = methodName.leftRef(parenIdx);

        if (methodNameRef == property) {
            rv.load(m);
            if (!isDynamicMetaObject(m.enclosingMetaObject()))
                rv.flags |= Data::IsDirect;
            return rv;
        }
    }

    return rv;
}
开发者ID:yinyunqiao,项目名称:qtdeclarative,代码行数:48,代码来源:qdeclarativepropertycache.cpp

示例4: validate_action_method

bool action_method::validate_action_method(const QMetaMethod &meta_method)
{
	auto meta_object = meta_method.enclosingMetaObject();
	if (!meta_object)
		throw exception::invalid_action{std::string{"action does not have enclosing meta object: "} + "?::" + meta_method.methodSignature().data()};
	if (meta_method.methodType() == QMetaMethod::Signal)
		throw exception::invalid_action{std::string{"action is signal: "} + meta_object->className() + "::" + meta_method.methodSignature().data()};
	if (meta_method.methodType() == QMetaMethod::Constructor)
		throw exception::invalid_action{std::string{"action is constructor: "} + meta_object->className() + "::" + meta_method.methodSignature().data()};
	if (!is_action_init_tag(meta_method.tag()) && !is_action_done_tag(meta_method.tag()))
		throw exception::invalid_action{std::string{"action does not have valid tag: "} + meta_object->className() + "::" + meta_method.methodSignature().data()};
	if (meta_method.parameterCount() != 0)
		throw exception::invalid_action{std::string{"invalid parameter count: "} + meta_object->className() + "::" + meta_method.methodSignature().data()};

	return true;
}
开发者ID:ovz,项目名称:injeqt,代码行数:16,代码来源:action-method.cpp

示例5:

action_method::action_method(QMetaMethod meta_method) :
	_object_type{meta_method.enclosingMetaObject()},
	_meta_method{std::move(meta_method)}
{
	assert(validate_action_method(meta_method));
}
开发者ID:ovz,项目名称:injeqt,代码行数:6,代码来源:action-method.cpp


注:本文中的QMetaMethod::enclosingMetaObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。