本文整理汇总了C++中QMetaMethod::getParameterTypes方法的典型用法代码示例。如果您正苦于以下问题:C++ QMetaMethod::getParameterTypes方法的具体用法?C++ QMetaMethod::getParameterTypes怎么用?C++ QMetaMethod::getParameterTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMetaMethod
的用法示例。
在下文中一共展示了QMetaMethod::getParameterTypes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: method
void tst_QMetaMethod::method()
{
QFETCH(QByteArray, signature);
QFETCH(int, returnType);
QFETCH(QByteArray, returnTypeName);
QFETCH(QList<int>, parameterTypes);
QFETCH(QList<QByteArray>, parameterTypeNames);
QFETCH(QList<QByteArray>, parameterNames);
QFETCH(QMetaMethod::MethodType, methodType);
QFETCH(QMetaMethod::Access, access);
QVERIFY(parameterTypes.size() == parameterTypeNames.size());
QVERIFY(parameterTypes.size() == parameterNames.size());
const QMetaObject *mo = &MethodTestObject::staticMetaObject;
int index = (methodType == QMetaMethod::Constructor)
? mo->indexOfConstructor(signature) : mo->indexOfMethod(signature);
QVERIFY(index != -1);
QMetaMethod method = (methodType == QMetaMethod::Constructor)
? mo->constructor(index) : mo->method(index);
QVERIFY(method.isValid());
QCOMPARE(method.methodType(), methodType);
QCOMPARE(method.access(), access);
QVERIFY(!method.methodSignature().isEmpty());
if (method.methodSignature() != signature) {
// QMetaMethod should always produce a semantically equivalent signature
int signatureIndex = (methodType == QMetaMethod::Constructor)
? mo->indexOfConstructor(method.methodSignature())
: mo->indexOfMethod(method.methodSignature());
QCOMPARE(signatureIndex, index);
}
QByteArray computedName = signature.left(signature.indexOf('('));
QCOMPARE(method.name(), computedName);
QCOMPARE(method.tag(), "");
QCOMPARE(method.returnType(), returnType);
QVERIFY(method.typeName() != 0);
if (QByteArray(method.typeName()) != returnTypeName) {
// QMetaMethod should always produce a semantically equivalent typename
QCOMPARE(QMetaType::type(method.typeName()), QMetaType::type(returnTypeName));
}
if (method.parameterTypes() != parameterTypeNames) {
// QMetaMethod should always produce semantically equivalent typenames
QList<QByteArray> actualTypeNames = method.parameterTypes();
QCOMPARE(actualTypeNames.size(), parameterTypeNames.size());
for (int i = 0; i < parameterTypeNames.size(); ++i) {
QCOMPARE(QMetaType::type(actualTypeNames.at(i)),
QMetaType::type(parameterTypeNames.at(i)));
}
}
QCOMPARE(method.parameterNames(), parameterNames);
QCOMPARE(method.parameterCount(), parameterTypes.size());
for (int i = 0; i < parameterTypes.size(); ++i)
QCOMPARE(method.parameterType(i), parameterTypes.at(i));
{
QVector<int> actualParameterTypes(parameterTypes.size());
method.getParameterTypes(actualParameterTypes.data());
for (int i = 0; i < parameterTypes.size(); ++i)
QCOMPARE(actualParameterTypes.at(i), parameterTypes.at(i));
}
// Bogus indexes
QCOMPARE(method.parameterType(-1), 0);
QCOMPARE(method.parameterType(parameterTypes.size()), 0);
}