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


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

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


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

示例1: setupConnections

    void ChainLink::setupConnections(const KoFilter *sender, const KoFilter *receiver) const
    {
        const QMetaObject * const parent = sender->metaObject();
        const QMetaObject * const child = receiver->metaObject();
        if (!parent || !child)
            return;

        int senderMethodCount = parent->methodCount();
        for (int i = 0; i < senderMethodCount; ++i) {
            QMetaMethod metaMethodSignal = parent->method(i);
            if (metaMethodSignal.methodType() != QMetaMethod::Signal)
                continue;
            // ### untested (QMetaMethod::signature())
            if (strncmp(metaMethodSignal.methodSignature(), SIGNAL_PREFIX, SIGNAL_PREFIX_LEN) == 0) {
                int receiverMethodCount = child->methodCount();
                for (int j = 0; j < receiverMethodCount; ++j) {
                    QMetaMethod metaMethodSlot = child->method(j);
                    if (metaMethodSlot.methodType() != QMetaMethod::Slot)
                        continue;
                    if (strncmp(metaMethodSlot.methodSignature().constData(), SLOT_PREFIX, SLOT_PREFIX_LEN) == 0) {
                        if (strcmp(metaMethodSignal.methodSignature().constData() + SIGNAL_PREFIX_LEN, metaMethodSlot.methodSignature().constData() + SLOT_PREFIX_LEN) == 0) {
                            QByteArray signalString;
                            signalString.setNum(QSIGNAL_CODE);
                            signalString += metaMethodSignal.methodSignature();
                            QByteArray slotString;
                            slotString.setNum(QSLOT_CODE);
                            slotString += metaMethodSlot.methodSignature();
                            QObject::connect(sender, signalString, receiver, slotString);
                        }
                    }
                }
            }
        }
    }
开发者ID:UIKit0,项目名称:calligra,代码行数:34,代码来源:KoFilterChainLink.cpp

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

示例3: on_comboMethods_activated

void InvokeMethod::on_comboMethods_activated(const QString &method)
{
    if (!activex)
        return;
    listParameters->clear();

    const QMetaObject *mo = activex->metaObject();
    const QMetaMethod slot = mo->method(mo->indexOfSlot(method.toLatin1()));
    QString signature = QString::fromLatin1(slot.methodSignature());
    signature = signature.mid(signature.indexOf(QLatin1Char('(')) + 1);
    signature.truncate(signature.length()-1);

    QList<QByteArray> pnames = slot.parameterNames();
    QList<QByteArray> ptypes = slot.parameterTypes();

    for (int p = 0; p < ptypes.count(); ++p) {
        QString ptype(QString::fromLatin1(ptypes.at(p)));
        if (ptype.isEmpty())
            continue;
        QString pname(QString::fromLatin1(pnames.at(p).constData()));
        if (pname.isEmpty())
            pname = QString::fromLatin1("<unnamed %1>").arg(p);
        QTreeWidgetItem *item = new QTreeWidgetItem(listParameters);
        item->setText(0, pname);
        item->setText(1, ptype);
    }

    if (listParameters->topLevelItemCount())
        listParameters->setCurrentItem(listParameters->topLevelItem(0));
    editReturn->setText(QString::fromLatin1(slot.typeName()));
}
开发者ID:James-intern,项目名称:Qt,代码行数:31,代码来源:invokemethod.cpp

示例4: setControl

void InvokeMethod::setControl(QAxBase *ax)
{
    activex = ax;
    bool hasControl = activex && !activex->isNull();
    labelMethods->setEnabled(hasControl);
    comboMethods->setEnabled(hasControl);
    buttonInvoke->setEnabled(hasControl);
    boxParameters->setEnabled(hasControl);

    comboMethods->clear();
    listParameters->clear();

    if (!hasControl) {
        editValue->clear();
        return;
    }

    const QMetaObject *mo = activex->metaObject();
    if (mo->methodCount()) {
        for (int i = mo->methodOffset(); i < mo->methodCount(); ++i) {
            const QMetaMethod method = mo->method(i);
            if (method.methodType() == QMetaMethod::Slot)
                comboMethods->addItem(QString::fromLatin1(method.methodSignature()));
        }
        comboMethods->model()->sort(0);

        on_comboMethods_activated(comboMethods->currentText());
    }
}
开发者ID:James-intern,项目名称:Qt,代码行数:29,代码来源:invokemethod.cpp

示例5: queryQSObject

QSObject QSAEditor::queryQSObject( const QMetaObject *meta, const QString &property, bool /*includeSuperClass*/ ) const
{
    int propertyIndex = -1;
    const QMetaObject *m = meta;
    propertyIndex = m->indexOfProperty(property.toLatin1().constData());

    if (propertyIndex >= 0) {
        QMetaProperty mp = m->property(propertyIndex);
        QSObject o = vTypeToQSType( QString::fromLatin1(mp.typeName()) );
	    if ( !o.isNull() && !o.isUndefined() )
	        return o;
    }

    m = meta;
    for (int i=0; i<m->methodCount(); ++i) {
        QMetaMethod mm = m->method(i);

        if (mm.methodType() == QMetaMethod::Slot) {
            QString n = QLatin1String(mm.methodSignature());
	        n = n.left(n.indexOf('('));
	        if ( property != n )
		        continue;

            return vTypeToQSType(mm.typeName());
        }
    }

    return env()->createUndefined();
}
开发者ID:aschet,项目名称:qsaqt5,代码行数:29,代码来源:qsaeditor.cpp

示例6: 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) {
                QByteArray sig = method.methodSignature();
                array.add(Identifier(exec, String(sig.constData(), sig.length())));
            }
        }
    }
}
开发者ID:webOS-ports,项目名称:webkit,代码行数:33,代码来源:qt_instance.cpp

示例7: retType

const QMetaObject *QSAEditor::queryQMetaObject( const QMetaObject *meta,
						      const QString &property,
						      bool /*includeSuperClass*/ ) const
{
    const QMetaObject *m = meta;
    for (int i=0; i<m->methodCount(); ++i) {
        QMetaMethod mm = m->method(i);
        if (mm.methodType() == QMetaMethod::Slot) {
            QString n = QLatin1String(mm.methodSignature());
            n = n.left(n.indexOf('('));

            if (property != n)
                continue ;

            QByteArray retType(mm.typeName());

            if (retType.count('*') == 1) {
                extern const QMetaObject *qsa_query_meta_object(const QByteArray &name);
                return qsa_query_meta_object(qsa_strip_stars(retType));
            }
        }
    }

    return 0;
}
开发者ID:aschet,项目名称:qsaqt5,代码行数:25,代码来源:qsaeditor.cpp

示例8: metaData

QVariant ObjectMethodModel::metaData(const QModelIndex &index, const QMetaMethod &method,
                                     int role) const
{
    if (role == Qt::DisplayRole && index.column() == 0) {
        return Util::prettyMethodSignature(method);
    } else if (role == ObjectMethodModelRole::MetaMethod) {
        return QVariant::fromValue(method);
    } else if (role == ObjectMethodModelRole::MetaMethodType && index.column() == 1) {
        return QVariant::fromValue(method.methodType());
    } else if (role == ObjectMethodModelRole::MethodAccess && index.column() == 2) {
        return QVariant::fromValue(method.access());
    } else if (role == ObjectMethodModelRole::MethodSignature && index.column() == 0) {
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
        return method.signature();
#else
        return method.methodSignature();
#endif
    } else if (role == ObjectMethodModelRole::MethodTag && index.column() == 0 && qstrlen(method.tag())) {
        return method.tag();
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
    } else if (role == ObjectMethodModelRole::MethodRevision && index.column() == 0) {
        return method.revision();
#endif
    } else if (role == ObjectMethodModelRole::MethodIssues && index.column() == 0) {
        const QMetaObject *mo = m_metaObject;
        while (mo->methodOffset() > index.row())
            mo = mo->superClass();
        const auto r = QMetaObjectValidator::checkMethod(mo, method);
        return r == QMetaObjectValidatorResult::NoIssue ? QVariant() : QVariant::fromValue(r);
    }
    return QVariant();
}
开发者ID:iamsergio,项目名称:GammaRay,代码行数:32,代码来源:objectmethodmodel.cpp

示例9: objToString

// Creates a string, describing an object, using meta-object introspection
QString objToString(const QObject *obj) {
    QStringList result;
    const QMetaObject *meta = obj->metaObject();
    result += QString("class %1 : public %2 {").arg(meta->className())
            .arg(meta->superClass()->className());
    for (auto i=0; i < meta->propertyCount(); ++i) {
        const QMetaProperty property = meta->property(i);
        QVariant value = obj->property(property.name());
        if (value.canConvert(QVariant::String))
            result += QString("  %1 %2 = %3;")
                    .arg(property.typeName())
                    .arg(property.name())
                    .arg(value.toString());
    }

    QString signalPrefix("");
    for (auto i=0; i < meta->methodCount(); ++i) {
        const QMetaMethod method = meta->method(i);
        const QMetaMethod::MethodType methodType = method.methodType();
        if (methodType == QMetaMethod::Signal)
            signalPrefix = QStringLiteral("Q_SIGNAL");
        else if (methodType == QMetaMethod::Slot)
            signalPrefix = QStringLiteral("Q_SLOT");
        result += QString("  %1 %2 %3;")
                .arg(signalPrefix)
                .arg(QVariant::typeToName(method.returnType()))
                .arg(QString(method.methodSignature()));
    }
    result += "};";
    return result.join("\n");
}
开发者ID:keitee,项目名称:kb,代码行数:32,代码来源:objtostring.cpp

示例10:

void Nuria::ObjectWrapperResourcePrivate::connectToSignal (QMetaMethod method) {
	// Connect objects' signal to our homegrown qt_metacall().
	int index = method.methodIndex ();
	if (!QMetaObject::connect (this->object, index, this, index, Qt::DirectConnection)) {
		nError() << "connect() failed on" << this->object << "for signal" << method.methodSignature ();
	}
	
}
开发者ID:NuriaProject,项目名称:Core,代码行数:8,代码来源:objectwrapperresource.cpp

示例11: QMetaMethod_name

static QByteArray QMetaMethod_name(const QMetaMethod &m)
{
    QByteArray sig = m.methodSignature();
    int paren = sig.indexOf('(');
    if (paren == -1)
        return sig;
    else
        return sig.left(paren);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:9,代码来源:qdeclarativeobjectscriptclass.cpp

示例12: connect

// Connect up a particular slot name, with optional arguments.
static void connect(QObject *qobj, PyObject *slot_obj,
        const QByteArray &slot_nm, const QByteArray &args)
{
    // Ignore if it's not an autoconnect slot.
    if (!slot_nm.startsWith("on_"))
        return;

    // Extract the names of the emitting object and the signal.
    int i;

    i = slot_nm.lastIndexOf('_');

    if (i - 3 < 1 || i + 1 >= slot_nm.size())
        return;

    QByteArray ename = slot_nm.mid(3, i - 3);
    QByteArray sname = slot_nm.mid(i + 1);

    // Find the emitting object and get its meta-object.
    QObject *eobj = qobj->findChild<QObject *>(ename);

    if (!eobj)
        return;

    const QMetaObject *mo = eobj->metaObject();

    // Got through the methods looking for a matching signal.
    for (int m = 0; m < mo->methodCount(); ++m)
    {
        QMetaMethod mm = mo->method(m);

        if (mm.methodType() != QMetaMethod::Signal)
            continue;

        QByteArray sig(mm.methodSignature());

        if (Chimera::Signature::name(sig) != sname)
            continue;

        // If we have slot arguments then they must match as well.
        if (!args.isEmpty() && Chimera::Signature::arguments(sig) != args)
            continue;

        QObject *receiver;
        QByteArray slot_sig;

        if (pyqt5_get_connection_parts(slot_obj, eobj, sig.constData(), false, &receiver, slot_sig) != sipErrorNone)
            continue;

        // Add the type character.
        sig.prepend('2');

        // Connect the signal.
        QObject::connect(eobj, sig.constData(), receiver, slot_sig.constData());
    }
}
开发者ID:ContaTP,项目名称:pyqt5,代码行数:57,代码来源:qpycore_qmetaobject_helpers.cpp

示例13: indexOfMethod_data

void tst_qmetaobject::indexOfMethod_data()
{
    QTest::addColumn<QByteArray>("method");
    const QMetaObject *mo = &QTreeView::staticMetaObject;
    for (int i = 0; i < mo->methodCount(); ++i) {
        QMetaMethod method = mo->method(i);
        QByteArray sig = method.methodSignature();
        QTest::newRow(sig) << sig;
    }
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:10,代码来源:main.cpp

示例14: metaData

QVariant ObjectMethodModel::metaData(const QModelIndex &index,
                                 const QMetaMethod &method, int role) const
{
  if (role == Qt::DisplayRole) {
    if (index.column() == 0) {
      return Util::prettyMethodSignature(method);
    }
    if (index.column() == 1) {
      switch (method.methodType()) {
      case QMetaMethod::Method:
        return tr("Method");
      case QMetaMethod::Constructor:
        return tr("Constructor");
      case QMetaMethod::Slot:
        return tr("Slot");
      case QMetaMethod::Signal:
        return tr("Signal");
      default:
        return tr("Unknown");
      }
    }
    if (index.column() == 2) {
      switch (method.access()) {
      case QMetaMethod::Public:
        return tr("Public");
      case QMetaMethod::Protected:
        return tr("Protected");
      case QMetaMethod::Private:
        return tr("Private");
      default:
        return tr("Unknown");
      }
    }
    if (index.column() == 3) {
      return method.tag();
    }
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
    if (index.column() == 4) {
      return QString::number(method.revision());
    }
#endif
  } else if (role == ObjectMethodModelRole::MetaMethod) {
    return QVariant::fromValue(method);
  } else if (role == ObjectMethodModelRole::MetaMethodType) {
    return QVariant::fromValue(method.methodType());
  } else if (role == ObjectMethodModelRole::MethodSignature) {
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    return method.signature();
#else
    return method.methodSignature();
#endif
  }
  return QVariant();
}
开发者ID:dfries,项目名称:GammaRay,代码行数:54,代码来源:objectmethodmodel.cpp

示例15: proxyToSourceSignal

/*!
    \internal

    Returns the signal that corresponds to \a proxySignal in the
    meta-object of the \a sourceObject.
*/
static QMetaMethod proxyToSourceSignal(const QMetaMethod &proxySignal, QObject *sourceObject)
{
    if (!proxySignal.isValid())
        return proxySignal;
    Q_ASSERT(proxySignal.methodType() == QMetaMethod::Signal);
    Q_ASSERT(sourceObject != 0);
    const QMetaObject *sourceMeta = sourceObject->metaObject();
    int sourceIndex = sourceMeta->indexOfSignal(proxySignal.methodSignature());
    Q_ASSERT(sourceIndex != -1);
    return sourceMeta->method(sourceIndex);
}
开发者ID:mer-packages,项目名称:qtpim,代码行数:17,代码来源:qcontactmanager.cpp


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