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


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

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


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

示例1: proxyAll

void QMediaAbstractControlServer::proxyAll()
{
    QMetaObject const*  mo = metaObject();
    int                 mc = mo->methodCount();
    int                 offset = QMediaAbstractControlServer::staticMetaObject.methodOffset();

    QString className = mo->className();

    for (int i = offset; i < mc; ++i)
    {
        QMetaMethod method = mo->method(i);

        switch (method.methodType())
        {
        case QMetaMethod::Signal:
            QtopiaIpcAdaptor::connect(this, QByteArray::number(QSIGNAL_CODE) + method.signature(),
                                      d->send, QByteArray::number(QMESSAGE_CODE) + method.signature());
            break;

        case QMetaMethod::Slot:
            if (method.access() == QMetaMethod::Public)
            {
                QtopiaIpcAdaptor::connect(d->recieve, QByteArray::number(QMESSAGE_CODE) + method.signature(),
                                          this, QByteArray::number(QSLOT_CODE) + method.signature());
            }
            break;

        case QMetaMethod::Method:
            break;
        }
    }
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:32,代码来源:qmediaabstractcontrolserver.cpp

示例2: proxy

/*!
    Sets up remote invocation proxies for all signals and public slots
    on this object, starting at the class specified by \a meta.

    Normally \a meta will be the \c staticMetaObject value for the
    immediate subclass of QAbstractIpcInterface.  It allows the proxying
    to be limited to a subset of the class hierarchy if more derived
    classes have signals and slots that should not be proxied.

    This method is useful when the subclass has many signals
    and slots, and it would be error-prone to proxy them individually
    with proxy().

    \sa proxy()
*/
void QAbstractIpcInterface::proxyAll( const QMetaObject& meta )
{
    // Only needed for the server at present.
    if ( d->mode != Server )
        return;

    // Find the starting point within the metaobject tree.
    const QMetaObject *current = metaObject();
    while ( current != 0 && current != &meta ) {
        current = current->superClass();
    }
    if ( ! current )
        return;

    // If we have been called multiple times, then only proxy
    // the ones we haven't done yet.
    int last = current->methodCount();
    if ( last > d->lastProxy ) {
        int index = d->lastProxy;
        d->lastProxy = last;
        for ( ; index < last; ++index ) {

            QMetaMethod method = current->method( index );
            if ( method.methodType() == QMetaMethod::Slot &&
                 method.access() == QMetaMethod::Public ) {
                QByteArray name = method.signature();
                QtopiaIpcAdaptor::connect( d->receive, "3" + name, this, "1" + name );
            } else if ( method.methodType() == QMetaMethod::Signal ) {
                QByteArray name = method.signature();
                QtopiaIpcAdaptor::connect( this, "2" + name, d->send, "3" + name );
            }
        }
    }
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:49,代码来源:qabstractipcinterface.cpp

示例3: qSignalDumperCallbackSlot

static void qSignalDumperCallbackSlot(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);
    if (!member.signature())
        return;

    if (QTest::ignoreLevel ||
            (QTest::ignoreClasses() && QTest::ignoreClasses()->contains(mo->className())))
        return;

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

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

    str += ") ";
    str += member.signature();
    qPrintMessage(str);
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:31,代码来源:qsignaldumper.cpp

示例4: connectObjectSlotsByName

void mafObjectBase::connectObjectSlotsByName(QObject *signal_object) {
    const QMetaObject *mo = this->metaObject();
    Q_ASSERT(mo);
    const QObjectList list = qFindChildren<QObject *>(signal_object, QString());
    for (int i = 0; i < mo->methodCount(); ++i) {
        QMetaMethod method_slot = mo->method(i);
        if (method_slot.methodType() != QMetaMethod::Slot)
            continue;
        const char *slot = mo->method(i).signature();
        if (slot[0] != 'o' || slot[1] != 'n' || slot[2] != '_')
            continue;
        bool foundIt = false;
        for(int j = 0; j < list.count(); ++j) {
            const QObject *co = list.at(j);
            QByteArray objName = co->objectName().toAscii();
            int len = objName.length();
            if (!len || qstrncmp(slot + 3, objName.data(), len) || slot[len+3] != '_')
                continue;
            int sigIndex = -1; //co->metaObject()->signalIndex(slot + len + 4);
            const QMetaObject *smo = co->metaObject();
            if (sigIndex < 0) { // search for compatible signals
                int slotlen = qstrlen(slot + len + 4) - 1;
                for (int k = 0; k < co->metaObject()->methodCount(); ++k) {
                    QMetaMethod method = smo->method(k);
                    if (method.methodType() != QMetaMethod::Signal)
                        continue;

                    if (!qstrncmp(method.signature(), slot + len + 4, slotlen)) {
                        const char *signal = method.signature();
                        QString event_sig = SIGNAL_SIGNATURE;
                        event_sig.append(signal);

                        QString observer_sig = CALLBACK_SIGNATURE;
                        observer_sig.append(slot);

                        if(connect(co, event_sig.toAscii(), this, observer_sig.toAscii())) {
                            qDebug() << mafTr("CONNECTED slot %1 with signal %2").arg(slot, signal);
                            foundIt = true;
                            break;
                        } else {
                            qWarning() << mafTr("Cannot connect slot %1 with signal %2").arg(slot, signal);
                        }
                    }
                }
            }
        }
        if (foundIt) {
            // we found our slot, now skip all overloads
            while (mo->method(i + 1).attributes() & QMetaMethod::Cloned)
                  ++i;
        } else if (!(mo->method(i).attributes() & QMetaMethod::Cloned)) {
            qWarning("QMetaObject::connectSlotsByName: No matching signal for %s", slot);
        }
    }
}
开发者ID:b3c,项目名称:MAF3,代码行数:55,代码来源:mafObjectBase.cpp

示例5: connectForwardingSignals

void FakeAkonadiServerCommand::connectForwardingSignals()
{
  for (int methodIndex = 0; methodIndex < metaObject()->methodCount(); ++methodIndex)
  {
    QMetaMethod mm = metaObject()->method(methodIndex);
    if (mm.methodType() == QMetaMethod::Signal && QString(mm.signature()).startsWith("emit_"))
    {
      int modelSlotIndex = m_model->metaObject()->indexOfSlot( QString ( mm.signature() ).remove( 0, 5 ).toLatin1().data() );
      Q_ASSERT( modelSlotIndex >= 0 );
      metaObject()->connect( this, methodIndex, m_model, modelSlotIndex );
    }
  }
}
开发者ID:lenggi,项目名称:kcalcore,代码行数:13,代码来源:fakeakonadiservercommand.cpp

示例6: unwrapSmoke

extern "C" SEXP qt_qmocMethods(SEXP x) {
  const QMetaObject *meta = unwrapSmoke(x, QMetaObject);
  int n = meta->methodCount();
  
  SEXP ans, ans_type, ans_signature, ans_return, ans_nargs;
  PROTECT(ans = allocVector(VECSXP, 4));
  ans_type = allocVector(INTSXP, n);
  SET_VECTOR_ELT(ans, 0, ans_type);
  ans_signature = allocVector(STRSXP, n);
  SET_VECTOR_ELT(ans, 1, ans_signature);
  ans_return = allocVector(STRSXP, n);
  SET_VECTOR_ELT(ans, 2, ans_return);
  ans_nargs = allocVector(INTSXP, n);
  SET_VECTOR_ELT(ans, 3, ans_nargs);    
  
  for (int i = 0; i < n; i++) {
    QMetaMethod metaMethod = meta->method(i);
    INTEGER(ans_type)[i] = metaMethod.methodType();
    SET_STRING_ELT(ans_signature, i, mkChar(metaMethod.signature()));
    SET_STRING_ELT(ans_return, i, mkChar(metaMethod.typeName()));
    INTEGER(ans_nargs)[i] = metaMethod.parameterNames().size();
  }
  
  UNPROTECT(1);
  return ans;
}
开发者ID:NickSpyrison,项目名称:qtbase,代码行数:26,代码来源:metaobject.cpp

示例7: getPropertyNames

void QtInstance::getPropertyNames(ExecState* exec, PropertyNameArray& array)
{
    // This is the enumerable properties, so put:
    // properties
    // dynamic properties
    // slots
    QObject* obj = getObject();
    if (obj) {
        const QMetaObject* meta = obj->metaObject();

        int i;
        for (i = 0; i < meta->propertyCount(); i++) {
            QMetaProperty prop = meta->property(i);
            if (prop.isScriptable())
                array.add(Identifier(exec, prop.name()));
        }

#ifndef QT_NO_PROPERTIES
        QList<QByteArray> dynProps = obj->dynamicPropertyNames();
        foreach (const QByteArray& ba, dynProps)
            array.add(Identifier(exec, ba.constData()));
#endif

        const int methodCount = meta->methodCount();
        for (i = 0; i < methodCount; i++) {
            QMetaMethod method = meta->method(i);
            if (method.access() != QMetaMethod::Private)
                array.add(Identifier(exec, method.signature()));
        }
    }
}
开发者ID:13W,项目名称:phantomjs,代码行数:31,代码来源:qt_instance.cpp

示例8: setupDBusInterface

static QScriptValue setupDBusInterface(QScriptEngine *engine, QDBusAbstractInterface *iface)
{
    QScriptValue v = engine->newQObject(iface);

    if (!qobject_cast<QDBusConnectionInterface *>(iface)) {
        const QMetaObject *mo = iface->metaObject();
        for (int i = 0; i < mo->methodCount(); ++i) {
            const QMetaMethod method = mo->method(i);
            const QByteArray signature = method.signature();
            //qDebug() << "signature" << signature;
            int parenIndex = signature.indexOf('(');
            if (parenIndex == -1)
                continue;
            const QByteArray name = signature.left(parenIndex);
            if (name.isEmpty())
                continue;

            // don't try to override properties
            if (mo->indexOfProperty(name) != -1)
                continue;

            QScriptValue callWrapper = engine->newFunction(do_dbus_call);
            callWrapper.setProperty("functionName", QScriptValue(engine, QString::fromAscii(name)));
            v.setProperty(QString(name), callWrapper);
        }
    }

    v.setProperty("service", QScriptValue(engine, iface->service()), QScriptValue::ReadOnly);
    v.setProperty("path", QScriptValue(engine, iface->path()), QScriptValue::ReadOnly);
    v.setProperty("interface", QScriptValue(engine, iface->interface()), QScriptValue::ReadOnly);
    v.setProperty("isValid", QScriptValue(engine, iface->isValid()), QScriptValue::ReadOnly);
    v.setProperty("connection", engine->newQObject(new QScriptDBusConnection(iface->connection(), engine)), QScriptValue::ReadOnly);

    return v;
}
开发者ID:pk-codebox-evo,项目名称:remixos-usb-tool,代码行数:35,代码来源:main.cpp

示例9: reloadAttributesList

void ServiceBrowser::reloadAttributesList()
{
    QListWidgetItem *item = interfacesListWidget->currentItem();
    if (!item)
        return;

    QServiceInterfaceDescriptor selectedImpl =
            item->data(Qt::UserRole).value<QServiceInterfaceDescriptor>();

    QObject *implementationRef;
    if (selectedImplRadioButton->isChecked())
        implementationRef = serviceManager->loadInterface(selectedImpl, 0, 0);
    else
        implementationRef = serviceManager->loadInterface(selectedImpl.interfaceName(), 0, 0);

    attributesListWidget->clear();
    if (!implementationRef) {
        attributesListWidget->addItem(tr("(Error loading service plugin)"));
        return;
    }

    const QMetaObject *metaObject = implementationRef->metaObject();
    attributesGroup->setTitle(tr("Invokable attributes for %1 class")
            .arg(QString(metaObject->className())));
    for (int i=0; i<metaObject->methodCount(); i++) {
        QMetaMethod method = metaObject->method(i);
        attributesListWidget->addItem("[METHOD] " + QString(method.signature()));
    }
    for (int i=0; i<metaObject->propertyCount(); i++) {
        QMetaProperty property = metaObject->property(i);
        attributesListWidget->addItem("[PROPERTY] " + QString(property.name()));
    }
}
开发者ID:Esclapion,项目名称:qt-mobility,代码行数:33,代码来源:servicebrowser.cpp

示例10: matchMetamethod

QList<QMetaMethod> matchMetamethod(QObject *object, QByteArray& methodName,
		QVariantList& args, QByteArray* retval) {
	const QMetaObject* meta = object->metaObject();
	QList<QMetaMethod> methods;
	for (int i = 0; i < meta->methodCount(); ++i) {
		QMetaMethod method = meta->method(i);
		if (QByteArray(method.signature()).startsWith(methodName + "("))
			methods.append(method);
	}
	if (methods.size() == 0) {
		retval->operator =("No such method " + methodName + " ");
		foreach (QVariant var, args)
			retval->append(var.toByteArray() + " ");
		retval->remove(retval->size() - 1, 1);
		return methods;
	}

// TODO: better algorithm
	QList<QMetaMethod> exactMethods;
	for (int i = 0; i < methods.size(); ++i) {
		if (methods[i].parameterNames().size() == args.size()) {
			exactMethods << methods[i];
		}
	}
	if (exactMethods.size() > 0)
		return exactMethods;
	return methods;
}
开发者ID:Balgam,项目名称:WebWorks-Community-APIs,代码行数:28,代码来源:QJnextMainLoop.cpp

示例11: Exception

	foreach (Listener *listener, listeners) {
		int methodCount = listener->metaObject()->methodCount();
		for (int i = 0; i < methodCount; ++i) {

			QMetaMethod slotMethod = listener->metaObject()->method(i);
			char const * const slotName = slotMethod.signature();
			int slotId = listener->metaObject()->indexOfSlot(slotName);

			if (slotMethod.access() != QMetaMethod::Public
				|| slotId == -1
				|| QString(slotName).startsWith("deleteLater"))
			{
				continue;
			}

			int thisMethodCount = this->metaObject()->methodCount();
			bool connected = false;
			for (int j = 0; j < thisMethodCount; ++j) {
				char const * const signalName = this->metaObject()->method(j).signature();

				if (signalName != QString(slotName))
					continue;

				int signalId = this->metaObject()->indexOfSignal(signalName);

				connected |= QMetaObject::connect(this, signalId, listener, slotId);
			}

			if (!connected)
				throw Exception("Unknown plugin event listener public slot " + QString(slotName));
		}
	}
开发者ID:nfrey,项目名称:qreal,代码行数:32,代码来源:listenerManager.cpp

示例12: name

static inline QByteArray getMethodName(const QMetaMethod& method) {
	QByteArray name(method.signature());
	int bracket = name.indexOf("(");
	if (bracket >= 0)
		name.remove(bracket, name.size() - bracket);
	return name;
}
开发者ID:Balgam,项目名称:WebWorks-Community-APIs,代码行数:7,代码来源:QJnextMainLoop.cpp

示例13: 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

示例14: while

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

    const char *returnType = m.typeName();
    if (returnType && *returnType) {
        propTypeName = returnType;
        flags |= Data::NotFullyResolved;
    }

    const char *signature = m.signature();
    while (*signature != '(') { Q_ASSERT(*signature != 0); ++signature; }

    ++signature;
    if (*signature != ')') {
        flags |= Data::HasArguments;
        if (0 == ::strcmp(signature, "QDeclarativeV8Function*)")) {
            flags |= Data::IsV8Function;
        }
    }

    revision = m.revision();
}
开发者ID:yinyunqiao,项目名称:qtdeclarative,代码行数:28,代码来源:qdeclarativepropertycache.cpp

示例15: lqtL_methods

static int lqtL_methods(lua_State *L) {
	QObject* self = static_cast<QObject*>(lqtL_toudata(L, 1, "QObject*"));
	if (self == NULL)
		return luaL_argerror(L, 1, "expecting QObject*");
	const QMetaObject *mo = self->metaObject();
	lua_createtable(L, mo->methodCount(), 0);
	for (int i=0; i < mo->methodCount(); i++) {
		QMetaMethod m = mo->method(i);
		lua_pushstring(L, m.signature());
		switch (m.access()) {
		CASE(Private);
		CASE(Protected);
		CASE(Public);
		}
		switch (m.methodType()) {
		CASE(Method);
		CASE(Signal);
		CASE(Slot);
		CASE(Constructor);
		}
		lua_concat(L, 3);
		lua_rawseti(L, -2, i+1);
	}
	return 1;
}
开发者ID:Abyss116,项目名称:luaplus51-all,代码行数:25,代码来源:lqt_qt.cpp


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