本文整理汇总了C++中QMetaObjectBuilder::serialize方法的典型用法代码示例。如果您正苦于以下问题:C++ QMetaObjectBuilder::serialize方法的具体用法?C++ QMetaObjectBuilder::serialize怎么用?C++ QMetaObjectBuilder::serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMetaObjectBuilder
的用法示例。
在下文中一共展示了QMetaObjectBuilder::serialize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: addSignal
bool Test::addSignal(const QString &signal)
{
if (d->signalName2Id.value(signal, -1) != -1)
return false;
QDataStream istream(d->metadata);
QMetaObjectBuilder builder;
QMap<QByteArray, const QMetaObject*> refs;
builder.deserialize(istream, refs);
int metaIndex = builder.addSignal(signal.toLocal8Bit()).index()
+ d->meta->methodOffset();
d->signalName2Id.insert(signal, metaIndex);
if (d->meta)
free(d->meta);
d->meta = builder.toMetaObject();
QDataStream ostream(&d->metadata, QIODevice::WriteOnly);
builder.serialize(ostream);
return true;
}
示例4: removeSlot
bool Test::removeSlot(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 = d->slotId2Name.key(slot);
builder.removeMethod(metaIndex - d->meta->methodOffset());
d->slotId2Name.remove(metaIndex);
if (d->meta)
free(d->meta);
d->meta = builder.toMetaObject();
QDataStream ostream(&d->metadata, QIODevice::WriteOnly);
builder.serialize(ostream);
return true;
}
示例5: removeSignal
bool Test::removeSignal(const QString &signal)
{
if (d->signalName2Id.value(signal, -1) == -1)
return false;
QDataStream istream(d->metadata);
QMetaObjectBuilder builder;
QMap<QByteArray, const QMetaObject*> refs;
builder.deserialize(istream, refs);
int metaIndex = d->signalName2Id.value(signal) - d->meta->methodOffset();
d->signalName2Id.remove(signal);
builder.removeMethod(metaIndex);
if (d->meta)
free(d->meta);
d->meta = builder.toMetaObject();
QDataStream ostream(&d->metadata, QIODevice::WriteOnly);
builder.serialize(ostream);
return true;
}