本文整理汇总了C++中QVariant::asCString方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariant::asCString方法的具体用法?C++ QVariant::asCString怎么用?C++ QVariant::asCString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariant
的用法示例。
在下文中一共展示了QVariant::asCString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: packVariant
static void packVariant( UibStrTable& strings, QDataStream& out,
QVariant value, QString tag = "" )
{
QStringList::ConstIterator s;
Q_UINT8 type = value.type();
if ( tag == "pixmap" ) {
type = QVariant::Pixmap;
} else if ( tag == "image" ) {
type = QVariant::Image;
} else if ( tag == "iconset" ) {
type = QVariant::IconSet;
}
out << type;
switch ( type ) {
case QVariant::String:
case QVariant::Pixmap:
case QVariant::Image:
case QVariant::IconSet:
packString( strings, out, value.asString() );
break;
case QVariant::StringList:
packUInt16( out, value.asStringList().count() );
s = value.asStringList().begin();
while ( s != value.asStringList().end() ) {
packString( strings, out, *s );
++s;
}
break;
case QVariant::Font:
out << value.asFont();
break;
case QVariant::Rect:
packUInt16( out, value.asRect().x() );
packUInt16( out, value.asRect().y() );
packUInt16( out, value.asRect().width() );
packUInt16( out, value.asRect().height() );
break;
case QVariant::Size:
packUInt16( out, value.asSize().width() );
packUInt16( out, value.asSize().height() );
break;
case QVariant::Color:
out << value.asColor();
break;
case QVariant::Point:
packUInt16( out, value.asPoint().x() );
packUInt16( out, value.asPoint().y() );
break;
case QVariant::Int:
packUInt32( out, value.asInt() );
break;
case QVariant::Bool:
out << (Q_UINT8) value.asBool();
break;
case QVariant::Double:
out << value.asDouble();
break;
case QVariant::CString:
packCString( strings, out, value.asCString() );
break;
case QVariant::Cursor:
out << value.asCursor();
break;
case QVariant::Date:
out << value.asDate();
break;
case QVariant::Time:
out << value.asTime();
break;
case QVariant::DateTime:
out << value.asDateTime();
break;
default:
out << value;
}
}