本文整理汇总了C++中QMetaObjectBuilder::setClassName方法的典型用法代码示例。如果您正苦于以下问题:C++ QMetaObjectBuilder::setClassName方法的具体用法?C++ QMetaObjectBuilder::setClassName怎么用?C++ QMetaObjectBuilder::setClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMetaObjectBuilder
的用法示例。
在下文中一共展示了QMetaObjectBuilder::setClassName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2:
QMetaObject *GoValue::metaObjectFor(GoTypeInfo *typeInfo)
{
if (typeInfo->metaObject) {
return reinterpret_cast<QMetaObject *>(typeInfo->metaObject);
}
QMetaObjectBuilder mob;
mob.setSuperClass(&QObject::staticMetaObject);
mob.setClassName(typeInfo->typeName);
mob.setFlags(QMetaObjectBuilder::DynamicMetaObject);
GoMemberInfo *memberInfo;
memberInfo = typeInfo->fields;
int relativePropIndex = mob.propertyCount();
for (int i = 0; i < typeInfo->fieldsLen; i++) {
mob.addSignal("__" + QByteArray::number(relativePropIndex) + "()");
QMetaPropertyBuilder propb = mob.addProperty(memberInfo->memberName, "QVariant", relativePropIndex);
propb.setWritable(true);
memberInfo->metaIndex = relativePropIndex;
memberInfo++;
relativePropIndex++;
}
memberInfo = typeInfo->methods;
int relativeMethodIndex = mob.methodCount();
for (int i = 0; i < typeInfo->methodsLen; i++) {
if (*memberInfo->resultSignature) {
mob.addMethod(memberInfo->methodSignature, memberInfo->resultSignature);
} else {
mob.addMethod(memberInfo->methodSignature);
}
memberInfo->metaIndex = relativeMethodIndex;
memberInfo++;
relativeMethodIndex++;
}
QMetaObject *mo = mob.toMetaObject();
// Turn the relative indexes into absolute indexes.
memberInfo = typeInfo->fields;
int propOffset = mo->propertyOffset();
for (int i = 0; i < typeInfo->fieldsLen; i++) {
memberInfo->metaIndex += propOffset;
memberInfo++;
}
memberInfo = typeInfo->methods;
int methodOffset = mo->methodOffset();
for (int i = 0; i < typeInfo->methodsLen; i++) {
memberInfo->metaIndex += methodOffset;
memberInfo++;
}
typeInfo->metaObject = mo;
return mo;
}
示例3: ostream
Test::Test(QObject *parent) :
QObject(parent), d(new TestPrivate)
{
QMetaObjectBuilder builder;
builder.setClassName("Test");
d->catchedSignalId = builder.addSignal("catched(QString,QVariantList)").index();
d->meta = builder.toMetaObject();
QDataStream ostream(&d->metadata, QIODevice::WriteOnly);
builder.serialize(ostream);
}
示例4:
void QDeclarative1OpenMetaObjectTypePrivate::init(const QMetaObject *metaObj)
{
if (!mem) {
mob.setSuperClass(metaObj);
mob.setClassName(metaObj->className());
mob.setFlags(QMetaObjectBuilder::DynamicMetaObject);
mem = mob.toMetaObject();
propertyOffset = mem->propertyOffset();
signalOffset = mem->methodOffset();
}
}
示例5: QObject
QServiceProxyBase::QServiceProxyBase(ObjectEndPoint *endpoint, QObject *parent)
: QObject(parent), d(0)
{
d = new QServiceProxyBasePrivate();
d->meta = 0;
d->endPoint = endpoint;
d->ipcfailure = -1;
d->timerId = startTimer(1000);
QMetaObjectBuilder sup;
sup.setClassName("QServiceProxyBase");
QMetaMethodBuilder b = sup.addSignal("errorUnrecoverableIPCFault(QService::UnrecoverableIPCError)");
d->ipcfailure = b.index();
d->meta = sup.toMetaObject();
d->ipcFailureSignal = d->meta->method(d->meta->methodOffset());
Q_ASSERT(d->ipcFailureSignal.methodSignature() == "errorUnrecoverableIPCFault(QService::UnrecoverableIPCError)");
}
示例6: 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();
}
示例7: 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);
}
}
示例8:
QMetaObject *metaObjectFor(GoTypeInfo *typeInfo)
{
if (typeInfo->metaObject) {
return reinterpret_cast<QMetaObject *>(typeInfo->metaObject);
}
QMetaObjectBuilder mob;
if (typeInfo->paint) {
mob.setSuperClass(&QQuickPaintedItem::staticMetaObject);
} else {
mob.setSuperClass(&QObject::staticMetaObject);
}
mob.setClassName(typeInfo->typeName);
mob.setFlags(QMetaObjectBuilder::DynamicMetaObject);
GoMemberInfo *memberInfo;
memberInfo = typeInfo->fields;
int relativePropIndex = mob.propertyCount();
for (int i = 0; i < typeInfo->fieldsLen; i++) {
mob.addSignal("__" + QByteArray::number(relativePropIndex) + "()");
const char *typeName = "QVariant";
if (memberInfo->memberType == DTListProperty) {
typeName = "QQmlListProperty<QObject>";
}
QMetaPropertyBuilder propb = mob.addProperty(memberInfo->memberName, typeName, relativePropIndex);
propb.setWritable(true);
memberInfo->metaIndex = relativePropIndex;
memberInfo++;
relativePropIndex++;
}
memberInfo = typeInfo->methods;
int relativeMethodIndex = mob.methodCount();
for (int i = 0; i < typeInfo->methodsLen; i++) {
if (*memberInfo->resultSignature) {
mob.addMethod(memberInfo->methodSignature, memberInfo->resultSignature);
} else {
mob.addMethod(memberInfo->methodSignature);
}
memberInfo->metaIndex = relativeMethodIndex;
memberInfo++;
relativeMethodIndex++;
}
// TODO Support default properties.
//mob.addClassInfo("DefaultProperty", "objects");
QMetaObject *mo = mob.toMetaObject();
// Turn the relative indexes into absolute indexes.
memberInfo = typeInfo->fields;
int propOffset = mo->propertyOffset();
for (int i = 0; i < typeInfo->fieldsLen; i++) {
memberInfo->metaIndex += propOffset;
memberInfo++;
}
memberInfo = typeInfo->methods;
int methodOffset = mo->methodOffset();
for (int i = 0; i < typeInfo->methodsLen; i++) {
memberInfo->metaIndex += methodOffset;
memberInfo++;
}
typeInfo->metaObject = mo;
return mo;
}
示例9: 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;
#if QT_VERSION >= 0x050000
QMetaObjectBuilder builder;
#endif
// Get any class info.
QList<ClassInfo> class_info_list = qpycore_get_class_info_list();
// Get the super-type's meta-object.
#if QT_VERSION >= 0x050000
builder.setSuperClass(get_qmetaobject((pyqtWrapperType *)pytype->tp_base));
#else
qo->mo.d.superdata = get_qmetaobject((pyqtWrapperType *)pytype->tp_base);
#endif
// Get the name of the type. Dynamic types have simple names.
#if QT_VERSION >= 0x050000
builder.setClassName(pytype->tp_name);
#else
qo->str_data = pytype->tp_name;
qo->str_data.append('\0');
#endif
// Go through the class dictionary getting all PyQt properties, slots,
// signals or a (deprecated) sequence of signals.
typedef QPair<PyObject *, PyObject *> prop_data;
QMap<uint, prop_data> pprops;
QList<QByteArray> psigs;
SIP_SSIZE_T pos = 0;
PyObject *key, *value;
#if QT_VERSION < 0x050000
bool has_notify_signal = false;
QList<const QMetaObject *> enum_scopes;
#endif
while (PyDict_Next(pytype->tp_dict, &pos, &key, &value))
{
// See if it is a slot, ie. it has been decorated with pyqtSlot().
PyObject *sig_obj = PyObject_GetAttr(value,
qpycore_signature_attr_name);
if (sig_obj)
{
// Make sure it is a list and not some legitimate attribute that
// happens to use our special name.
if (PyList_Check(sig_obj))
{
for (SIP_SSIZE_T i = 0; i < PyList_GET_SIZE(sig_obj); ++i)
{
qpycore_slot slot;
// Set up the skeleton slot.
PyObject *decoration = PyList_GET_ITEM(sig_obj, i);
slot.signature = Chimera::Signature::fromPyObject(decoration);
slot.sip_slot.pyobj = 0;
slot.sip_slot.name = 0;
slot.sip_slot.meth.mfunc = value;
slot.sip_slot.meth.mself = 0;
#if PY_MAJOR_VERSION < 3
slot.sip_slot.meth.mclass = (PyObject *)pyqt_wt;
#endif
slot.sip_slot.weakSlot = 0;
qo->pslots.append(slot);
}
}
Py_DECREF(sig_obj);
}
else
{
PyErr_Clear();
// Make sure the key is an ASCII string. Delay the error checking
// until we know we actually need it.
const char *ascii_key = sipString_AsASCIIString(&key);
// See if the value is of interest.
if (PyType_IsSubtype(Py_TYPE(value), &qpycore_pyqtProperty_Type))
{
// It is a property.
if (!ascii_key)
return -1;
Py_INCREF(value);
qpycore_pyqtProperty *pp = (qpycore_pyqtProperty *)value;
pprops.insert(pp->pyqtprop_sequence, prop_data(key, value));
// See if the property has a scope. If so, collect all
// QMetaObject pointers that are not in the super-class
//.........这里部分代码省略.........
示例10: 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)
//.........这里部分代码省略.........
示例11: clone
static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd)
{
// Set classname
builder.setClassName(ignoreEnd->className());
// Clone Q_CLASSINFO
for (int ii = mo->classInfoOffset(); ii < mo->classInfoCount(); ++ii) {
QMetaClassInfo info = mo->classInfo(ii);
int otherIndex = ignoreEnd->indexOfClassInfo(info.name());
if (otherIndex >= ignoreStart->classInfoOffset() + ignoreStart->classInfoCount()) {
// Skip
} else {
builder.addClassInfo(info.name(), info.value());
}
}
// Clone Q_PROPERTY
for (int ii = mo->propertyOffset(); ii < mo->propertyCount(); ++ii) {
QMetaProperty property = mo->property(ii);
int otherIndex = ignoreEnd->indexOfProperty(property.name());
if (otherIndex >= ignoreStart->propertyOffset() + ignoreStart->propertyCount()) {
builder.addProperty(QByteArray("__qml_ignore__") + property.name(), QByteArray("void"));
// Skip
} else {
builder.addProperty(property);
}
}
// Clone Q_METHODS
for (int ii = mo->methodOffset(); ii < mo->methodCount(); ++ii) {
QMetaMethod method = mo->method(ii);
// More complex - need to search name
QByteArray name = method.name();
bool found = false;
for (int ii = ignoreStart->methodOffset() + ignoreStart->methodCount();
!found && ii < ignoreEnd->methodOffset() + ignoreEnd->methodCount();
++ii) {
QMetaMethod other = ignoreEnd->method(ii);
found = name == other.name();
}
QMetaMethodBuilder m = builder.addMethod(method);
if (found) // SKIP
m.setAccess(QMetaMethod::Private);
}
// Clone Q_ENUMS
for (int ii = mo->enumeratorOffset(); ii < mo->enumeratorCount(); ++ii) {
QMetaEnum enumerator = mo->enumerator(ii);
int otherIndex = ignoreEnd->indexOfEnumerator(enumerator.name());
if (otherIndex >= ignoreStart->enumeratorOffset() + ignoreStart->enumeratorCount()) {
// Skip
} else {
builder.addEnumerator(enumerator);
}
}
}
示例12: 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();
//.........这里部分代码省略.........