本文整理汇总了C++中QVariant::asDateTime方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariant::asDateTime方法的具体用法?C++ QVariant::asDateTime怎么用?C++ QVariant::asDateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariant
的用法示例。
在下文中一共展示了QVariant::asDateTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: formatProperties
void formatProperties( const QMap<int,KTNEFProperty*>& props, QListView *lv, QListViewItem *item, const QString& prefix )
{
for ( QMap<int,KTNEFProperty*>::ConstIterator it=props.begin(); it!=props.end(); ++it )
{
QListViewItem *newItem = 0;
if ( lv )
newItem = new QListViewItem( lv, ( *it )->keyString() );
else if ( item )
newItem = new QListViewItem( item, ( *it )->keyString() );
else
{
kdWarning() << "formatProperties() called with no listview and no item" << endl;
return;
}
QVariant value = ( *it )->value();
if ( value.type() == QVariant::List )
{
newItem->setOpen( true );
newItem->setText( 0, newItem->text( 0 ) + " [" + QString::number( value.asList().count() ) + "]" );
int i = 0;
for ( QValueList<QVariant>::ConstIterator lit=value.listBegin(); lit!=value.listEnd(); ++lit, i++ )
new QListViewItem( newItem, "[" + QString::number( i ) + "]", KTNEFProperty::formatValue( *lit ) );
}
else if ( value.type() == QVariant::DateTime )
newItem->setText( 1, value.asDateTime().toString() );
else
{
newItem->setText( 1, ( *it )->valueString() );
newItem->setText( 2, prefix + "_" + QString::number( it.key() ) );
}
}
}
示例2: 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;
}
}
示例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();
}