本文整理汇总了C++中QVariant::asColor方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariant::asColor方法的具体用法?C++ QVariant::asColor怎么用?C++ QVariant::asColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariant
的用法示例。
在下文中一共展示了QVariant::asColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: outputProperty
static void outputProperty( QMap<int, QStringList>& buddies, int objectNo,
UibStrTable& strings, QDataStream& out,
QDomElement elem )
{
QCString name = elem.attribute( "name" ).latin1();
QDomElement f = elem.firstChild().toElement();
QString tag = f.tagName();
QString comment;
QVariant value;
if ( name == "resizeable" )
name = "resizable";
if ( tag == "font" ) {
QString family;
Q_UINT16 pointSize = 65535;
Q_UINT8 fontFlags = 0;
QDomElement g = f.firstChild().toElement();
while ( !g.isNull() ) {
QString text = g.firstChild().toText().data();
if ( g.tagName() == "family" ) {
fontFlags |= Font_Family;
family = text;
} else if ( g.tagName() == "pointsize" ) {
fontFlags |= Font_PointSize;
pointSize = (Q_UINT16) text.toUInt();
} else {
if ( g.firstChild().toText().data().toInt() != 0 ) {
if ( g.tagName() == "bold" ) {
fontFlags |= Font_Bold;
} else if ( g.tagName() == "italic" ) {
fontFlags |= Font_Italic;
} else if ( g.tagName() == "underline" ) {
fontFlags |= Font_Underline;
} else if ( g.tagName() == "strikeout" ) {
fontFlags |= Font_StrikeOut;
}
}
}
g = g.nextSibling().toElement();
}
out << (Q_UINT8) Object_FontProperty;
packCString( strings, out, name );
out << fontFlags;
if ( fontFlags & Font_Family )
packString( strings, out, family );
if ( fontFlags & Font_PointSize )
packUInt16( out, pointSize );
} else if ( tag == "palette" ) {
out << (Q_UINT8) Object_PaletteProperty;
packCString( strings, out, name );
QDomElement g = f.firstChild().toElement();
while ( !g.isNull() ) {
QDomElement h = g.firstChild().toElement();
while ( !h.isNull() ) {
value = DomTool::elementToVariant( h, Qt::gray );
if ( h.tagName() == "color" ) {
out << (Q_UINT8) Palette_Color;
out << value.asColor();
} else if ( h.tagName() == "pixmap" ) {
out << (Q_UINT8) Palette_Pixmap;
packVariant( strings, out, value, "pixmap" );
}
h = h.nextSibling().toElement();
}
if ( g.tagName() == "active" ) {
out << (Q_UINT8) Palette_Active;
} else if ( g.tagName() == "inactive" ) {
out << (Q_UINT8) Palette_Inactive;
} else {
out << (Q_UINT8) Palette_Disabled;
}
g = g.nextSibling().toElement();
}
out << (Q_UINT8) Palette_End;
} else {
value = DomTool::elementToVariant( f, value, comment );
if ( value.isValid() ) {
if ( name == "buddy" ) {
buddies[objectNo] += value.asString();
} else {
if ( tag == "string" ) {
out << (Q_UINT8) Object_TextProperty;
packCString( strings, out, name );
packCString( strings, out, value.asString().utf8() );
packCString( strings, out, comment.utf8() );
} else {
out << (Q_UINT8) Object_VariantProperty;
packCString( strings, out, name );
packVariant( strings, out, value, tag );
}
}
}
}
}
示例3: readPropertyEntry
QVariant KConfigBase::readPropertyEntry(const char *pKey, const QVariant &aDefault) const
{
if(!hasKey(pKey))
return aDefault;
QVariant tmp = aDefault;
switch(aDefault.type())
{
case QVariant::Invalid:
return QVariant();
case QVariant::String:
return QVariant(readEntry(pKey, aDefault.toString()));
case QVariant::StringList:
return QVariant(readListEntry(pKey));
case QVariant::List:
{
QStringList strList = readListEntry(pKey);
QStringList::ConstIterator it = strList.begin();
QStringList::ConstIterator end = strList.end();
QValueList< QVariant > list;
for(; it != end; ++it)
{
tmp = *it;
list.append(tmp);
}
return QVariant(list);
}
case QVariant::Font:
return QVariant(readFontEntry(pKey, &tmp.asFont()));
case QVariant::Point:
return QVariant(readPointEntry(pKey, &tmp.asPoint()));
case QVariant::Rect:
return QVariant(readRectEntry(pKey, &tmp.asRect()));
case QVariant::Size:
return QVariant(readSizeEntry(pKey, &tmp.asSize()));
case QVariant::Color:
return QVariant(readColorEntry(pKey, &tmp.asColor()));
case QVariant::Int:
return QVariant(readNumEntry(pKey, aDefault.toInt()));
case QVariant::UInt:
return QVariant(readUnsignedNumEntry(pKey, aDefault.toUInt()));
case QVariant::LongLong:
return QVariant(readNum64Entry(pKey, aDefault.toLongLong()));
case QVariant::ULongLong:
return QVariant(readUnsignedNum64Entry(pKey, aDefault.toULongLong()));
case QVariant::Bool:
return QVariant(readBoolEntry(pKey, aDefault.toBool()), 0);
case QVariant::Double:
return QVariant(readDoubleNumEntry(pKey, aDefault.toDouble()));
case QVariant::DateTime:
return QVariant(readDateTimeEntry(pKey, &tmp.asDateTime()));
case QVariant::Date:
return QVariant(readDateTimeEntry(pKey, &tmp.asDateTime()).date());
case QVariant::Pixmap:
case QVariant::Image:
case QVariant::Brush:
case QVariant::Palette:
case QVariant::ColorGroup:
case QVariant::Map:
case QVariant::IconSet:
case QVariant::CString:
case QVariant::PointArray:
case QVariant::Region:
case QVariant::Bitmap:
case QVariant::Cursor:
case QVariant::SizePolicy:
case QVariant::Time:
case QVariant::ByteArray:
case QVariant::BitArray:
case QVariant::KeySequence:
case QVariant::Pen:
break;
}
Q_ASSERT(0);
return QVariant();
}