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


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

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


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

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

示例2: 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 signal = parent->method(i);
            if (signal.methodType() != QMetaMethod::Signal)
                continue;
            // ### untested (QMetaMethod::signature())
            if (strncmp(signal.signature(), SIGNAL_PREFIX, SIGNAL_PREFIX_LEN) == 0) {
                int receiverMethodCount = child->methodCount();
                for (int j = 0; j < receiverMethodCount; ++j) {
                    QMetaMethod slot = child->method(j);
                    if (slot.methodType() != QMetaMethod::Slot)
                        continue;
                    if (strncmp(slot.signature(), SLOT_PREFIX, SLOT_PREFIX_LEN) == 0) {
                        if (strcmp(signal.signature() + SIGNAL_PREFIX_LEN, slot.signature() + SLOT_PREFIX_LEN) == 0) {
                            QByteArray signalString;
                            signalString.setNum(QSIGNAL_CODE);
                            signalString += signal.signature();
                            QByteArray slotString;
                            slotString.setNum(QSLOT_CODE);
                            slotString += slot.signature();
                            QObject::connect(sender, signalString, receiver, slotString);
                        }
                    }
                }
            }
        }
    }
开发者ID:KDE,项目名称:koffice,代码行数:34,代码来源:KoFilterChainLink.cpp

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

示例4:

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

示例5: 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");
      }
    }
  } else if (role == Qt::ToolTipRole) {
    QString tt = Util::prettyMethodSignature(method);
    tt += tr("\nTag: %1\n").arg(qstrlen(method.tag()) > 0 ? method.tag() : tr("<none>"));
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
    tt += tr("Revision: %1").arg(method.revision());
#endif
    return tt;
  } 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:netrunner-debian-kde-extras,项目名称:gammaray,代码行数:53,代码来源:objectmethodmodel.cpp

示例6: if

static int
qt_connect(lua_State *L)
{
  // LUA: "qt.connect(object signal closure)" 
  // Connects signal to closure.
  
  // LUA: "qt.connect(object signal object signal_or_slot)"
  // Connects signal to signal or slot.
  
  QObject *obj = luaQ_checkqobject<QObject>(L, 1);
  const char *sig = luaL_checkstring(L, 2);
  QObject *robj = luaQ_toqobject(L, 3);
  if (robj)
    {
      // search signal or slot
      QByteArray rsig = luaL_checkstring(L, 4);
      const QMetaObject *mo = robj->metaObject();
      int idx = mo->indexOfMethod(rsig.constData());
      if (idx < 0)
        {
          rsig = QMetaObject::normalizedSignature(rsig.constData());
          idx = mo->indexOfMethod(rsig.constData());
          if (idx < 0)
            luaL_error(L, "cannot find target slot or signal %s", 
                       rsig.constData());
        }
      // prepend signal or slot indicator
      QMetaMethod method = mo->method(idx);
      if (method.methodType() == QMetaMethod::Signal)
        rsig.prepend('0' + QSIGNAL_CODE);
      else if (method.methodType() == QMetaMethod::Slot)
        rsig.prepend('0' + QSLOT_CODE);
      else
        luaL_error(L, "target %s is not a slot or a signal",
                   rsig.constData());
      // connect
      QByteArray ssig = sig;
      ssig.prepend('0' + QSIGNAL_CODE);
      if (! QObject::connect(obj, ssig.constData(), robj, rsig.constData()))
        luaL_error(L, "cannot find source signal %s", sig);
    }
  else
    {
      luaL_checktype(L, 3, LUA_TFUNCTION);
      bool direct = lua_toboolean(L, 4);
      if (direct)
        luaL_checktype(L, 4, LUA_TBOOLEAN);
      if (! luaQ_connect(L, obj, sig, 3, direct))
        luaL_error(L, "cannot find source signal %s", sig);
    }
  return 0;
}
开发者ID:2ndforks,项目名称:torch7-custom,代码行数:52,代码来源:qtluautils.cpp

示例7: activateMethod

void PropertyController::activateMethod()
{
  QItemSelectionModel* selectionModel = ObjectBroker::selectionModel(m_methodModel);
  if (selectionModel->selectedRows().size() != 1)
    return;
  const QModelIndex index = selectionModel->selectedRows().first();

  const QMetaMethod method = index.data(ObjectMethodModelRole::MetaMethod).value<QMetaMethod>();
  if (method.methodType() == QMetaMethod::Slot) {
    m_methodArgumentModel->setMethod(method);
  } else if (method.methodType() == QMetaMethod::Signal) {
    m_signalMapper->connectToSignal(m_object, method);
  }
}
开发者ID:bschuste,项目名称:GammaRay,代码行数:14,代码来源:propertycontroller.cpp

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

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

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

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

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

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

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

/*!
    \internal
    Catch signal disconnections.
*/
void QDBusAbstractInterface::disconnectNotify(const QMetaMethod &signal)
{
    // someone disconnecting from one of our signals
    Q_D(QDBusAbstractInterface);
    if (!d->isValid)
        return;

    QDBusConnectionPrivate *conn = d->connectionPrivate();
    if (conn && signal.isValid() && !isSignalConnected(signal))
        return conn->disconnectRelay(d->service, d->path, d->interface,
                                     this, signal);
    if (!conn)
        return;

    // wildcard disconnecting, we need to figure out which of our signals are
    // no longer connected to anything
    const QMetaObject *mo = metaObject();
    int midx = QObject::staticMetaObject.methodCount();
    const int end = mo->methodCount();
    for ( ; midx < end; ++midx) {
        QMetaMethod mm = mo->method(midx);
        if (mm.methodType() == QMetaMethod::Signal && !isSignalConnected(mm))
            conn->disconnectRelay(d->service, d->path, d->interface, this, mm);
    }
}
开发者ID:xjohncz,项目名称:qt5,代码行数:29,代码来源:qdbusabstractinterface.cpp


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