本文整理汇总了C++中QSObject::toVariant方法的典型用法代码示例。如果您正苦于以下问题:C++ QSObject::toVariant方法的具体用法?C++ QSObject::toVariant怎么用?C++ QSObject::toVariant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSObject
的用法示例。
在下文中一共展示了QSObject::toVariant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertToArgument
QSArgument QuickInterpreter::convertToArgument( const QSObject &o )
{
if( !o.isValid() )
return QSArgument();
const QSClass *cl = o.objectType();
if( cl->name() == QString::fromLatin1("QObject") ) {
QSWrapperShared *shared = (QSWrapperShared*) o.shVal();
if (shared->objects.isEmpty())
return QSArgument();
return QSArgument( shared->objects[0] );
} else if( cl == ptrClass ) {
Q_ASSERT( ptrClass->pointer( &o ) );
return QSArgument( ptrClass->pointer( &o ) );
} else {
return QSArgument( o.toVariant( QVariant::Invalid ) );
}
}
示例2: convertToArgument
QVariant QuickInterpreter::convertToArgument(const QSObject &o)
{
if(!o.isValid())
return QVariant();
const QSClass *cl = o.objectType();
if(cl->name() == QString::fromLatin1("QObject")) {
QSWrapperShared *shared = (QSWrapperShared*) o.shVal();
if (shared->objects.isEmpty())
return QVariant();
QVariant v(QMetaType::QObjectStar, static_cast<QObject *>(0));
qVariantSetValue<QObject *>(v, shared->objects[0]);
return v;
} else if(cl == ptrClass) {
Q_ASSERT(ptrClass->pointer(&o));
QVariant v(QMetaType::VoidStar, static_cast<void *>(0));
qVariantSetValue<void *>(v, ptrClass->pointer(&o));
return v;
} else {
return QVariant(o.toVariant(QVariant::Invalid));
}
}