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


C++ QMetaObjectBuilder::addSlot方法代码示例

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


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

示例1: BuildMetaObject

			void WrapperObject::BuildMetaObject ()
			{
				QString path = QFileInfo (Path_).absolutePath ();
				QDir scriptDir (path);

				QMetaObjectBuilder builder;

				builder.setSuperClass (QObject::metaObject ());
				builder.setClassName (QString ("LeechCraft::Plugins::Qross::%1::%2")
							.arg (Type_)
							.arg (SCALL (QString) ("GetName").remove (' ')).toLatin1 ());

				int currentMetaMethod = 0;

				if (scriptDir.exists ("ExportedSlots"))
				{
					QFile slotsFile (scriptDir.filePath ("ExportedSlots"));
					slotsFile.open (QIODevice::ReadOnly);
					QList<QByteArray> sigSlots = slotsFile.readAll ().split ('\n');
					Q_FOREACH (QByteArray signature, sigSlots)
					{
						signature = signature.trimmed ();
						if (signature.isEmpty ())
							continue;
						Index2ExportedSignatures_ [currentMetaMethod++] = signature;
						builder.addSlot (signature);
					}
开发者ID:Apkawa,项目名称:leechcraft,代码行数:27,代码来源:wrapperobject.cpp

示例2: qMakePair

QMetaObject *DosQMetaObject::createMetaObject(const QString &className,
                                              const SignalDefinitions &signalDefinitions,
                                              const SlotDefinitions &slotDefinitions,
                                              const PropertyDefinitions &propertyDefinitions)
{
    QMetaObjectBuilder builder;
    builder.setClassName(className.toUtf8());
    builder.setSuperClass(m_superClassDosMetaObject->metaObject());

    for (const SignalDefinition &signal : signalDefinitions) {
        QMetaMethodBuilder signalBuilder = builder.addSignal(::createSignature(signal));
        signalBuilder.setReturnType(QMetaType::typeName(QMetaType::Void));
        signalBuilder.setAccess(QMetaMethod::Public);
        signalBuilder.setParameterNames(createParameterNames(signal));
        m_signalIndexByName[signal.name] = signalBuilder.index();
    }

    QHash<QString, int> methodIndexByName;
    for (const SlotDefinition &slot : slotDefinitions) {
        QMetaMethodBuilder methodBuilder = builder.addSlot(::createSignature(slot));
        methodBuilder.setReturnType(QMetaType::typeName(slot.returnType));
        methodBuilder.setAttributes(QMetaMethod::Scriptable);
        methodIndexByName[slot.name] = methodBuilder.index();
    }

    for (const PropertyDefinition &property : propertyDefinitions) {
        const int writer = methodIndexByName.value(property.writeSlot, -1);
        const int notifier = m_signalIndexByName.value(property.notifySignal, -1);
        const QByteArray name = property.name.toUtf8();
        const QByteArray typeName = QMetaObject::normalizedType(QMetaType::typeName(property.type));
        QMetaPropertyBuilder propertyBuilder = builder.addProperty(name, typeName, notifier);
        if (writer == -1)
            propertyBuilder.setWritable(false);
        if (notifier == -1)
            propertyBuilder.setConstant(true);
        m_propertySlots[property.name] = qMakePair(methodIndexByName.value(property.readSlot, -1),
                                                   methodIndexByName.value(property.writeSlot, -1));
    }

    return builder.toMetaObject();
}
开发者ID:refaqtor,项目名称:DOtherSide,代码行数:41,代码来源:DosQMetaObject.cpp

示例3: addSlot

bool Test::addSlot(const QString &slot)
{
    if (d->slotId2Name.key(slot, -1) != -1)
        return false;

    QDataStream istream(d->metadata);
    QMetaObjectBuilder builder;
    QMap<QByteArray, const QMetaObject*> refs;
    builder.deserialize(istream, refs);

    int metaIndex = builder.addSlot(slot.toLocal8Bit()).index();
    d->slotId2Name.insert(metaIndex + d->meta->methodOffset(), slot);

    if (d->meta)
        free(d->meta);
    d->meta = builder.toMetaObject();
    QDataStream ostream(&d->metadata, QIODevice::WriteOnly);
    builder.serialize(ostream);

    return true;
}
开发者ID:romixlab,项目名称:trunk,代码行数:21,代码来源:test.cpp

示例4: QObject

// Create a universal proxy used as a slot.  Note that this will leak if there
// is no transmitter and this is not a single shot slot.  There will be no
// meta-object if there was a problem creating the proxy.  This is called
// without the GIL.
PyQtSlotProxy::PyQtSlotProxy(PyObject *slot, QObject *q_tx,
        const Chimera::Signature *slot_signature, bool single_shot)
    : QObject(), proxy_flags(single_shot ? PROXY_SINGLE_SHOT : 0),
        signature(slot_signature->signature), transmitter(q_tx)
{
    SIP_BLOCK_THREADS
    real_slot = new PyQtSlot(slot, slot_signature);
    SIP_UNBLOCK_THREADS

    // Create a new meta-object on the heap so that it looks like it has a slot
    // of the right name and signature.
    QMetaObjectBuilder builder;

    builder.setClassName("PyQtSlotProxy");
    builder.setSuperClass(&QObject::staticMetaObject);

    builder.addSlot("unislot()");
    builder.addSlot("disable()");

    meta_object = builder.toMetaObject();

    // Detect when any transmitter is destroyed.  (Note that we used to do this
    // by making the proxy a child of the transmitter.  This doesn't work as
    // expected because QWidget destroys its children before emitting the
    // destroyed signal.)  We use a queued connection in case the proxy is also
    // connected to the same signal and we want to make sure it has a chance to
    // invoke the slot before being destroyed.
    if (transmitter)
    {
        // Add this one to the global hash.
        mutex->lock();
        proxy_slots.insert(transmitter, this);
        mutex->unlock();

        connect(transmitter, SIGNAL(destroyed(QObject *)), SLOT(disable()),
                Qt::QueuedConnection);
    }
}
开发者ID:HunterChen,项目名称:pyqt5,代码行数:42,代码来源:qpycore_pyqtslotproxy.cpp

示例5: create_dynamic_metaobject


//.........这里部分代码省略.........
#endif
#endif

    // Add the signals to the meta-object.
    for (int g = 0; g < qo->nr_signals; ++g)
    {
        const QByteArray &norm = psigs.at(g);

#if QT_VERSION >= 0x050000
        builder.addSignal(norm.mid(1));
#else
        // Add the (non-existent) argument names.
        data[g_offset + (g * 5) + 1] = add_arg_names(qo, norm, empty);

        // Add the full signature.
        data[g_offset + (g * 5) + 0] = qo->str_data.size();
        qo->str_data.append(norm.constData() + 1);
        qo->str_data.append('\0');

        // Add the type, tag and flags.
        data[g_offset + (g * 5) + 2] = empty;
        data[g_offset + (g * 5) + 3] = empty;
        data[g_offset + (g * 5) + 4] = 0x05;
#endif
    }

    // Add the slots to the meta-object.
    for (int s = 0; s < qo->pslots.count(); ++s)
    {
        const qpycore_slot &slot = qo->pslots.at(s);
        const QByteArray &sig = slot.signature->signature;

#if QT_VERSION >= 0x050000
        QMetaMethodBuilder slot_builder = builder.addSlot(sig);
#else
        // Add the (non-existent) argument names.
        data[s_offset + (s * 5) + 1] = add_arg_names(qo, sig, empty);

        // Add the full signature.
        data[s_offset + (s * 5) + 0] = qo->str_data.size();
        qo->str_data.append(sig);
        qo->str_data.append('\0');
#endif

        // Add any type.
        if (slot.signature->result)
        {
#if QT_VERSION >= 0x050000
            slot_builder.setReturnType(slot.signature->result->name());
#else
            data[s_offset + (s * 5) + 2] = qo->str_data.size();
            qo->str_data.append(slot.signature->result->name());
            qo->str_data.append('\0');
#endif
        }
#if QT_VERSION < 0x050000
        else
        {
            data[s_offset + (s * 5) + 2] = empty;
        }

        // Add the tag and flags.
        data[s_offset + (s * 5) + 3] = empty;
        data[s_offset + (s * 5) + 4] = 0x0a;
#endif
    }
开发者ID:thaisdb,项目名称:TCC,代码行数:67,代码来源:qpycore_types.cpp

示例6: create_dynamic_metaobject

// Create a dynamic meta-object for a Python type by introspecting its
// attributes.  Note that it leaks if the type is deleted.
static int create_dynamic_metaobject(pyqtWrapperType *pyqt_wt)
{
    PyTypeObject *pytype = (PyTypeObject *)pyqt_wt;
    qpycore_metaobject *qo = new qpycore_metaobject;
    QMetaObjectBuilder builder;

    // Get any class info.
    QList<ClassInfo> class_info_list = qpycore_get_class_info_list();

    // Get any enums/flags.
    QList<EnumsFlags> enums_flags_list = qpycore_get_enums_flags_list();

    // Get the super-type's meta-object.
    builder.setSuperClass(get_qmetaobject((pyqtWrapperType *)pytype->tp_base));

    // Get the name of the type.  Dynamic types have simple names.
    builder.setClassName(pytype->tp_name);

    // Go through the class hierarchy getting all PyQt properties, slots and
    // signals.

    QList<const qpycore_pyqtSignal *> psigs;
    QMap<uint, PropertyData> pprops;

    if (trawl_hierarchy(pytype, qo, builder, psigs, pprops) < 0)
        return -1;

    qo->nr_signals = psigs.count();

    // Initialise the header section of the data table.  Note that Qt v4.5
    // introduced revision 2 which added constructors.  However the design is
    // broken in that the static meta-call function doesn't provide enough
    // information to determine which Python sub-class of a Qt class is to be
    // created.  So we stick with revision 1 (and don't allow pyqtSlot() to
    // decorate __init__).

    // Set up any class information.
    for (int i = 0; i < class_info_list.count(); ++i)
    {
        const ClassInfo &ci = class_info_list.at(i);

        builder.addClassInfo(ci.first, ci.second);
    }

    // Set up any enums/flags.
    for (int i = 0; i < enums_flags_list.count(); ++i)
    {
        const EnumsFlags &ef = enums_flags_list.at(i);

        QByteArray scoped_name(pytype->tp_name);
        scoped_name.append("::");
        scoped_name.append(ef.name);
        QMetaEnumBuilder enum_builder = builder.addEnumerator(scoped_name);

        enum_builder.setIsFlag(ef.isFlag);

        QHash<QByteArray, int>::const_iterator it = ef.keys.constBegin();

        while (it != ef.keys.constEnd())
        {
            enum_builder.addKey(it.key(), it.value());
            ++it;
        }
    }

    // Add the signals to the meta-object.
    for (int g = 0; g < qo->nr_signals; ++g)
    {
        const qpycore_pyqtSignal *ps = psigs.at(g);

        QMetaMethodBuilder signal_builder = builder.addSignal(
                ps->parsed_signature->signature.mid(1));

        if (ps->parameter_names)
            signal_builder.setParameterNames(*ps->parameter_names);

        signal_builder.setRevision(ps->revision);
    }

    // Add the slots to the meta-object.
    for (int s = 0; s < qo->pslots.count(); ++s)
    {
        const Chimera::Signature *slot_signature = qo->pslots.at(s)->slotSignature();
        const QByteArray &sig = slot_signature->signature;

        QMetaMethodBuilder slot_builder = builder.addSlot(sig);

        // Add any type.
        if (slot_signature->result)
            slot_builder.setReturnType(slot_signature->result->name());

        slot_builder.setRevision(slot_signature->revision);
    }

    // Add the properties to the meta-object.
    QMapIterator<uint, PropertyData> it(pprops);

    for (int p = 0; it.hasNext(); ++p)
//.........这里部分代码省略.........
开发者ID:ContaTP,项目名称:pyqt5,代码行数:101,代码来源:qpycore_types.cpp

示例7: init

// Initialisation common to all ctors.
void PyQtProxy::init(QObject *qtx, PyQtProxy::ProxyHash *hash, void *key)
{
    // Create a new meta-object on the heap so that it looks like it has a
    // signal of the right name and signature.
#if QT_VERSION >= 0x050000
    QMetaObjectBuilder builder;

    builder.setClassName("PyQtProxy");
    builder.setSuperClass(&QObject::staticMetaObject);

    // Note that signals must be added before slots.
    if (type == ProxySignal)
        builder.addSignal(signature);
    else
        builder.addSlot("unislot()");

    builder.addSlot("disable()");

    meta_object = builder.toMetaObject();
#else
    if (type == ProxySignal)
    {
        QMetaObject *mo = new QMetaObject;
        mo->d.superdata = &QObject::staticMetaObject;
        mo->d.extradata = 0;

        // Calculate the size of the string meta-data as follows:
        // - "PyQtProxy" and its terminating '\0' (ie. 9 + 1 bytes),
        // - a '\0' used for any empty string,
        // - "disable()" and its terminating '\0' (ie. 9 + 1 bytes),
        // - the (non-existent) argument names (ie. use the empty string if
        //   there is less that two arguments, otherwise a comma between each
        //   argument and the terminating '\0'),
        // - the name and full signature, less the initial type character, plus
        //   the terminating '\0'.

        const size_t fixed_len = 9 + 1 + 1 + 9 + 1;
        const size_t empty_str = 9 + 1;

        int nr_commas = signature.count(',');

        size_t len = fixed_len
                    + (nr_commas >= 0 ? nr_commas + 1 : 0)
                    + signature.size() + 1;

        char *smd = new char[len];

        memcpy(smd, slot_meta_stringdata, fixed_len);

        uint i = fixed_len, args_pos;

        if (nr_commas > 0)
        {
            args_pos = i;

            for (int c = 0; c < nr_commas; ++c)
                smd[i++] = ',';

            smd[i++] = '\0';
        }
        else
        {
            args_pos = empty_str;
        }

        uint sig_pos = i;
        qstrcpy(&smd[i], signature.constData());

        mo->d.stringdata = smd;

        // Add the non-string data.
        uint *data = new uint[21];

        memcpy(data, slot_meta_data, 21 * sizeof (uint));

        // Replace the first method (ie. unislot()) with the new signal.
        data[10] = sig_pos;
        data[11] = args_pos;
        data[14] = 0x05;

        mo->d.data = data;

        meta_object = mo;
    }
    else
    {
        meta_object = &staticMetaObject;
    }
#endif

    hashed = true;
    saved_key = key;
    transmitter = qtx;

    // Add this one to the global hashes.
    mutex->lock();
    hash->insert(key, this);
    mutex->unlock();

//.........这里部分代码省略.........
开发者ID:AlexDoul,项目名称:PyQt4,代码行数:101,代码来源:qpycore_pyqtproxy.cpp


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