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


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

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


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

示例1: methodCompat

bool QbElement::methodCompat(QMetaMethod method1, QMetaMethod method2)
{
    if (method1.parameterTypes() == method2.parameterTypes())
        return true;

    return false;
}
开发者ID:DYFeng,项目名称:Webcamoid,代码行数:7,代码来源:qbelement.cpp

示例2: getReturnType

QByteArray MaiaXmlRpcServerConnection::getReturnType( const QMetaObject *obj,
                                                      const QByteArray &method,
                                                      const QList<QByteArray> &argTypes )
{
    for( int n = 0; n < obj->methodCount(); ++n ) {
        QMetaMethod m = obj->method(n);
#if QT_VERSION >= 0x050000
        if( m.name() == method && m.parameterTypes() == argTypes ) {
            return m.typeName();
        }
#else
        QByteArray sig = m.signature();

        int offset = sig.indexOf('(');
        if( offset == -1 ) {
            continue;
        }

        QByteArray name = sig.mid(0, offset);
        if( name == method && m.parameterTypes() == argTypes ) {
            return m.typeName();
        }
#endif
    }
    return QByteArray();

} // QByteArray getReturnType( const QMetaObject *obj, const QByteArray &method, const QList<QByteArray> &argTypes )
开发者ID:naihil,项目名称:libmaia,代码行数:27,代码来源:maiaXmlRpcServerConnection.cpp

示例3: bind

    /*!
     * Creates a binding to the provided signal, slot, or Q_INVOKABLE method using the
     * provided parameter list. The type of each argument is deduced from the type of
     * the QVariant. This function cannot bind positional arguments; see the
     * overload using QGenericArgument.
     *
     * If the provided QObject does not implement the requested method, or if the
     * argument list is incompatible with the method's function signature, this
     * function returns NULL.
     *
     * The returned QxtBoundFunction is created as a child of the receiver.
     * Changing the parent will result in undefined behavior.
     *
     * \sa QxtMetaObject::connect, QxtBoundFunction
     */
    QxtBoundFunction* bind(QObject* recv, const char* invokable, QXT_IMPL_10ARGS(QVariant))
    {
        if (!recv)
        {
            qWarning() << "QxtMetaObject::bind: cannot connect to null QObject";
            return 0;
        }

        QVariant* args[10] = { &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10 };
        QByteArray connSlot("2"), recvSlot(QMetaObject::normalizedSignature(invokable));
        const QMetaObject* meta = recv->metaObject();
        int methodID = meta->indexOfMethod(QxtMetaObject::methodSignature(recvSlot.constData()));
        if (methodID == -1)
        {
            qWarning() << "QxtMetaObject::bind: no such method " << recvSlot;
            return 0;
        }
        QMetaMethod method = meta->method(methodID);
        int argCount = method.parameterTypes().count();
        const QList<QByteArray> paramTypes = method.parameterTypes();

        for (int i = 0; i < argCount; i++)
        {
            if (paramTypes[i] == "QxtBoundArgument") continue;
            int type = QMetaType::type(paramTypes[i].constData());
            if (!args[i]->canConvert((QVariant::Type)type))
            {
                qWarning() << "QxtMetaObject::bind: incompatible parameter list for " << recvSlot;
                return 0;
            }
        }

        return QxtMetaObject::bind(recv, invokable, QXT_ARG(1), QXT_ARG(2), QXT_ARG(3), QXT_ARG(4), QXT_ARG(5), QXT_ARG(6), QXT_ARG(7), QXT_ARG(8), QXT_ARG(9), QXT_ARG(10));
    }
开发者ID:AidedPolecat6,项目名称:tomahawk,代码行数:49,代码来源:qxtmetaobject.cpp

示例4: getDbusSignature

static QString getDbusSignature(const QMetaMethod& method)
{
    // create a D-Bus type signature from QMetaMethod's parameters
    QString sig;
    for (int i = 0; i < method.parameterTypes().count(); ++i) {
        QVariant::Type type = QVariant::nameToType(method.parameterTypes().at(i));
        sig.append(QString::fromLatin1(QDBusMetaType::typeToSignature(type)));
    }
    return sig;
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:10,代码来源:qdbusviewer.cpp

示例5: connect

void QJnextMainLoop::connect(QObject *object, uint id, QVariantList& args,
		QByteArray *retval) {
	QByteArray methodName = args.takeFirst().toByteArray();
	QByteArray sid = args.takeFirst().toByteArray();
	int argCount = -1;

	const QMetaObject* meta = object->metaObject();
	QMetaMethod method;
	for (int i = 0; i < meta->methodCount(); ++i) {
		method = meta->method(i);
		if (QByteArray(method.signature()).startsWith(methodName + "(")) {
			QList<QByteArray> types = method.parameterTypes();
			if (types.size() > argCount) {
				// TODO : always pick enum types
				argCount = method.parameterTypes().size();
				break;
			}
		}
	}
	if (argCount == -1) {
		*retval = "No signal named " + methodName + " found";
		return;
	}
#ifdef DEBUG_QJnextMainLoop
	qDebug() << "[QJnextMainLoop]\tSIGNAL.connect" << methodName << id << sid;
#endif

	QJnextUserData * jnextData = dynamic_cast<QJnextUserData*>(object->userData(
			QJnextMainLoop::userDataId));
	if (jnextData == NULL) {
		*retval = "Unable to retrieve jnextData from object "
				+ QByteArray::number(id);
		return;
	}

	SignalHandler *& handler = jnextData->signalHandlers[sid];
	if (handler != NULL) {
#ifdef DEBUG_QJnextMainLoop
		qDebug() << "[QJnextMainLoop]\tCONNECTED (chained)";
#endif
		return;
	}
	handler = new SignalHandler(this, object, id, "com.blackberry.qt" + sid, meta, method);
	if (!handler->isValid()) {
		*retval = "QMetaObject::connect returned false. Unable to connect";
		return;
	}
#ifdef DEBUG_QJnextMainLoop
	qDebug() << "[QJnextMainLoop]\tCONNECTED";
#endif
}
开发者ID:Balgam,项目名称:WebWorks-Community-APIs,代码行数:51,代码来源:QJnextMainLoop.cpp

示例6: signature

int /* search the meta data for a match to the name and args */
MocClass::findMethodId(Smoke *smoke, const QMetaObject *meta, const char *name,
                       SEXP args) const
{
  int result = -1;
  int classId = smoke->idClass(meta->className()).index;
  if (!args) return result; // Do not (yet?) support calls from Smoke
  while (classId == 0) {
    // go in reverse to choose most derived method first
    for (int id = meta->methodCount()-1; id >= 0; id--) {
      QMetaMethod meth = meta->method(id);
      if (meth.access() != QMetaMethod::Private) {
        QByteArray signature(meta->method(id).signature());
        QByteArray methodName = signature.mid(0, signature.indexOf('('));
        // Don't check that the types of the R args match
        // the c++ ones for now,
        // only that the name and arg count is the same.
        if (methodName == name &&
            meth.parameterTypes().count() == length(args))
          result = id;
      }
    }
    meta = meta->superClass();
    classId = smoke->idClass(meta->className()).index;
  }
  
  return result;
}
开发者ID:rforge,项目名称:qtinterfaces,代码行数:28,代码来源:MocClass.cpp

示例7: Value

QDeclarativeObjectMethodScriptClass::Value 
QDeclarativeObjectMethodScriptClass::callPrecise(QObject *object, const QDeclarativePropertyCache::Data &data, 
                                                 QScriptContext *ctxt)
{
    if (data.flags & QDeclarativePropertyCache::Data::HasArguments) {

        QMetaMethod m = object->metaObject()->method(data.coreIndex);
        QList<QByteArray> argTypeNames = m.parameterTypes();
        QVarLengthArray<int, 9> argTypes(argTypeNames.count());

        // ### Cache
        for (int ii = 0; ii < argTypeNames.count(); ++ii) {
            argTypes[ii] = QMetaType::type(argTypeNames.at(ii));
            if (argTypes[ii] == QVariant::Invalid) 
                argTypes[ii] = enumType(object->metaObject(), QString::fromLatin1(argTypeNames.at(ii)));
            if (argTypes[ii] == QVariant::Invalid) 
                return Value(ctxt, ctxt->throwError(QString::fromLatin1("Unknown method parameter type: %1").arg(QLatin1String(argTypeNames.at(ii)))));
        }

        if (argTypes.count() > ctxt->argumentCount())
            return Value(ctxt, ctxt->throwError(QLatin1String("Insufficient arguments")));

        return callMethod(object, data.coreIndex, data.propType, argTypes.count(), argTypes.data(), ctxt);

    } else {

        return callMethod(object, data.coreIndex, data.propType, 0, 0, ctxt);

    }
}
开发者ID:fluxer,项目名称:katie,代码行数:30,代码来源:qdeclarativeobjectscriptclass.cpp

示例8: callMethod

void QDBusViewer::callMethod(const BusSignature &sig)
{
    QDBusInterface iface(sig.mService, sig.mPath, sig.mInterface, c);
    const QMetaObject *mo = iface.metaObject();

    // find the method
    QMetaMethod method;
    for (int i = 0; i < mo->methodCount(); ++i) {
        const QString signature = QString::fromLatin1(mo->method(i).signature());
        if (signature.startsWith(sig.mName) && signature.at(sig.mName.length()) == QLatin1Char('('))
            if (getDbusSignature(mo->method(i)) == sig.mTypeSig)
                method = mo->method(i);
    }
    if (!method.signature()) {
        QMessageBox::warning(this, tr("Unable to find method"),
                tr("Unable to find method %1 on path %2 in interface %3").arg(
                    sig.mName).arg(sig.mPath).arg(sig.mInterface));
        return;
    }

    PropertyDialog dialog;
    QList<QVariant> args;

    const QList<QByteArray> paramTypes = method.parameterTypes();
    const QList<QByteArray> paramNames = method.parameterNames();
    QList<int> types; // remember the low-level D-Bus type
    for (int i = 0; i < paramTypes.count(); ++i) {
        const QByteArray paramType = paramTypes.at(i);
        if (paramType.endsWith('&'))
            continue; // ignore OUT parameters

        QVariant::Type type = QVariant::nameToType(paramType);
        dialog.addProperty(QString::fromLatin1(paramNames.value(i)), type);
        types.append(QMetaType::type(paramType));
    }

    if (!types.isEmpty()) {
        dialog.setInfo(tr("Please enter parameters for the method \"%1\"").arg(sig.mName));

        if (dialog.exec() != QDialog::Accepted)
            return;

        args = dialog.values();
    }

    // Special case - convert a value to a QDBusVariant if the
    // interface wants a variant
    for (int i = 0; i < args.count(); ++i) {
        if (types.at(i) == qMetaTypeId<QDBusVariant>())
            args[i] = qVariantFromValue(QDBusVariant(args.at(i)));
    }

    QDBusMessage message = QDBusMessage::createMethodCall(sig.mService, sig.mPath, sig.mInterface,
            sig.mName);
    message.setArguments(args);
    c.callWithCallback(message, this, SLOT(dumpMessage(QDBusMessage)));
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:57,代码来源:qdbusviewer.cpp

示例9: qSignalDumperCallback

static void qSignalDumperCallback(QObject *caller, int method_index, void **argv)
{
    Q_ASSERT(caller);
    Q_ASSERT(argv);
    Q_UNUSED(argv);
    const QMetaObject *mo = caller->metaObject();
    Q_ASSERT(mo);
    QMetaMethod member = mo->method(method_index);
    Q_ASSERT(member.signature());

    if (QTest::ignoreClasses() && QTest::ignoreClasses()->contains(mo->className())) {
        ++QTest::ignoreLevel;
        return;
    }

    QByteArray str;
    str.fill(' ', QTest::iLevel++ * QTest::IndentSpacesCount);
    str += "Signal: ";
    str += mo->className();
    str += '(';

    QString objname = caller->objectName();
    str += objname.toLocal8Bit();
    if (!objname.isEmpty())
        str += ' ';
    str += QByteArray::number(quintptr(caller), 16);

    str += ") ";
    str += QTest::memberName(member);
    str += " (";

    QList<QByteArray> args = member.parameterTypes();
    for (int i = 0; i < args.count(); ++i) {
        const QByteArray &arg = args.at(i);
        int typeId = QMetaType::type(args.at(i).constData());
        if (arg.endsWith('*') || arg.endsWith('&')) {
            str += '(';
            str += arg;
            str += ')';
            if (arg.endsWith('&'))
                str += '@';

            quintptr addr = quintptr(*reinterpret_cast<void **>(argv[i + 1]));
            str.append(QByteArray::number(addr, 16));
        } else if (typeId != QMetaType::Void) {
            str.append(arg)
            .append('(')
            .append(QVariant(typeId, argv[i + 1]).toString().toLocal8Bit())
            .append(')');
        }
        str.append(", ");
    }
    if (str.endsWith(", "))
        str.chop(2);
    str.append(')');
    qPrintMessage(str);
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:57,代码来源:qsignaldumper.cpp

示例10: make_setter_method

setter_method make_setter_method(const types_by_name &known_types, const QMetaMethod &meta_method)
{
	auto parameter_type = meta_method.parameterCount() == 1
		? type_by_pointer(known_types, meta_method.parameterTypes()[0].data())
		: type{nullptr};
	setter_method::validate_setter_method(parameter_type, meta_method);

	return setter_method{parameter_type, meta_method};
}
开发者ID:ovz,项目名称:injeqt,代码行数:9,代码来源:setter-method.cpp

示例11: argTypes

    /**
     * \brief Extract the arguments types of a meta method
     *
     * \param metaMethod Qt meta method
     *
     * \return Arguments types of the meta method
     */
    static std::vector<ponder::Type> argTypes(const QMetaMethod& metaMethod)
    {
        std::vector<ponder::Type> types;

        QList<QByteArray> args = metaMethod.parameterTypes();
        Q_FOREACH(QByteArray arg, args)
        {
            types.push_back(QtHelper::type(arg));
        }
开发者ID:APTriTec,项目名称:ponder,代码行数:16,代码来源:qtfunction.hpp

示例12: signature

QString DataWidgetBinder::signature(QMetaMethod metaMethod) {
	QString str = metaMethod.name();
	str += "(";
	for(QByteArray t : metaMethod.parameterTypes()) {
		str += QString(t);
		str += "/";
	}
	str.chop(1);
	str += ")";
	return str;
}
开发者ID:Winded,项目名称:DataWidgetBinder,代码行数:11,代码来源:datawidgetbinder.cpp

示例13: listInterface

void listInterface(const QString &service, const QString &path, const QString &interface)
{
    QDBusInterfacePtr iface(*connection, service, path, interface);
    if (!iface->isValid()) {
        QDBusError err(iface->lastError());
        fprintf(stderr, "Interface '%s' not available in object %s at %s:\n%s (%s)\n",
                qPrintable(interface), qPrintable(path), qPrintable(service),
                qPrintable(err.name()), qPrintable(err.message()));
        exit(1);
    }
    const QMetaObject *mo = iface->metaObject();

    // properties
    for (int i = mo->propertyOffset(); i < mo->propertyCount(); ++i) {
        QMetaProperty mp = mo->property(i);
        printf("property ");

        if (mp.isReadable() && mp.isWritable())
            printf("readwrite");
        else if (mp.isReadable())
            printf("read");
        else
            printf("write");

        printf(" %s %s.%s\n", mp.typeName(), qPrintable(interface), mp.name());
    }

    // methods (signals and slots)
    for (int i = mo->methodOffset(); i < mo->methodCount(); ++i) {
        QMetaMethod mm = mo->method(i);

        QByteArray signature = mm.signature();
        signature.truncate(signature.indexOf('('));
        printf("%s %s%s%s %s.%s(",
               mm.methodType() == QMetaMethod::Signal ? "signal" : "method",
               mm.tag(), *mm.tag() ? " " : "",
               *mm.typeName() ? mm.typeName() : "void",
               qPrintable(interface), signature.constData());

        QList<QByteArray> types = mm.parameterTypes();
        QList<QByteArray> names = mm.parameterNames();
        bool first = true;
        for (int i = 0; i < types.count(); ++i) {
            printf("%s%s",
                   first ? "" : ", ",
                   types.at(i).constData());
            if (!names.at(i).isEmpty())
                printf(" %s", names.at(i).constData());
            first = false;
        }
        printf(")\n");
    }
}
开发者ID:freedesktop-unofficial-mirror,项目名称:dbus__dbus-qt3,代码行数:53,代码来源:dbus.cpp

示例14:

void QDeclarativePropertyCache::Data::load(const QMetaMethod &m)
{
    coreIndex = m.methodIndex();
    relatedIndex = -1;
    flags |= Data::IsFunction;
    if (m.methodType() == QMetaMethod::Signal)
        flags |= Data::IsSignal;
    propType = m.returnType();

    QList<QByteArray> params = m.parameterTypes();
    if (!params.isEmpty())
        flags |= Data::HasArguments;
    revision = m.revision();
}
开发者ID:mortenelund,项目名称:qt,代码行数:14,代码来源:qdeclarativepropertycache.cpp

示例15: convertArgs

bool JsonRpcServer::convertArgs(const QMetaMethod& meta_method,
                                const QVariantMap& args,
                                QVariantList& converted_args)
{
    QList<QByteArray> param_types = meta_method.parameterTypes();
    if (args.size() != param_types.size()) {
        logError(QString("wrong number of arguments to method %1 -- "
                         "expected %2 arguments, but got %3")
                 .arg(QString(meta_method.methodSignature()))
                 .arg(meta_method.parameterCount())
                 .arg(args.size()));
        return false;
    }

    for (int i = 0; i < param_types.size(); i++) {
        QByteArray param_name = meta_method.parameterNames().at(i);
        if (args.find(param_name) == args.end()) {
            // no arg with param name found
            return false;
        }
        const QVariant& arg = args.value(param_name);
        if (!arg.isValid()) {
            logError(QString("argument %1 of %2 to method %3 is invalid")
                     .arg(i + 1)
                     .arg(param_types.size())
                     .arg(QString(meta_method.methodSignature())));
            return false;
        }

        QByteArray arg_type_name = arg.typeName();
        QByteArray param_type_name = param_types.at(i);

        QVariant::Type param_type = QVariant::nameToType(param_type_name);

        QVariant copy = QVariant(arg);

        if (copy.type() != param_type) {
            if (copy.canConvert(param_type)) {
                if (!copy.convert(param_type)) {
                    // qDebug() << "cannot convert" << arg_type_name
                    //          << "to" << param_type_name;
                    return false;
                }
            }
        }

        converted_args << copy;
    }
    return true;
}
开发者ID:joncol,项目名称:jcon-cpp,代码行数:50,代码来源:json_rpc_server.cpp


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