<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qvariant.cpp:353 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>QVariant Class</title> <style type="text/css"><!-- fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QVariant Class Reference</h1> <p>The QVariant class acts like a union for the most common Qt data types. <a href="#details">More...</a> <p><tt>#include <<a href="qvariant-h.html">qvariant.h</a>></tt> <p><a href="qvariant-members.html">List of all member functions.</a> <h2>Public Members</h2> <ul> <li class=fn>enum <a href="#Type-enum"><b>Type</b></a> { Invalid, Map, List, String, StringList, Font, Pixmap, Brush, Rect, Size, Color, Palette, ColorGroup, IconSet, Point, Image, Int, UInt, Bool, Double, CString, PointArray, Region, Bitmap, Cursor, SizePolicy, Date, Time, DateTime, ByteArray, BitArray, KeySequence, Pen, LongLong, ULongLong }</li> <li class=fn><a href="#QVariant"><b>QVariant</b></a> ()</li> <li class=fn><a href="#~QVariant"><b>~QVariant</b></a> ()</li> <li class=fn><a href="#QVariant-2"><b>QVariant</b></a> ( const QVariant & p )</li> <li class=fn><a href="#QVariant-3"><b>QVariant</b></a> ( QDataStream & s )</li> <li class=fn><a href="#QVariant-4"><b>QVariant</b></a> ( const QString & val )</li> <li class=fn><a href="#QVariant-5"><b>QVariant</b></a> ( const QCString & val )</li> <li class=fn><a href="#QVariant-6"><b>QVariant</b></a> ( const char * val )</li> <li class=fn><a href="#QVariant-7"><b>QVariant</b></a> ( const QStringList & val )</li> <li class=fn><a href="#QVariant-8"><b>QVariant</b></a> ( const QFont & val )</li> <li class=fn><a href="#QVariant-9"><b>QVariant</b></a> ( const QPixmap & val )</li> <li class=fn><a href="#QVariant-a"><b>QVariant</b></a> ( const QImage & val )</li> <li class=fn><a href="#QVariant-b"><b>QVariant</b></a> ( const QBrush & val )</li> <li class=fn><a href="#QVariant-c"><b>QVariant</b></a> ( const QPoint & val )</li> <li class=fn><a href="#QVariant-d"><b>QVariant</b></a> ( const QRect & val )</li> <li class=fn><a href="#QVariant-e"><b>QVariant</b></a> ( const QSize & val )</li> <li class=fn><a href="#QVariant-f"><b>QVariant</b></a> ( const QColor & val )</li> <li class=fn><a href="#QVariant-g"><b>QVariant</b></a> ( const QPalette & val )</li> <li class=fn><a href="#QVariant-h"><b>QVariant</b></a> ( const QColorGroup & val )</li> <li class=fn><a href="#QVariant-i"><b>QVariant</b></a> ( const QIconSet & val )</li> <li class=fn><a href="#QVariant-j"><b>QVariant</b></a> ( const QPointArray & val )</li> <li class=fn><a href="#QVariant-k"><b>QVariant</b></a> ( const QRegion & val )</li> <li class=fn><a href="#QVariant-l"><b>QVariant</b></a> ( const QBitmap & val )</li> <li class=fn><a href="#QVariant-m"><b>QVariant</b></a> ( const QCursor & val )</li> <li class=fn><a href="#QVariant-n"><b>QVariant</b></a> ( const QDate & val )</li> <li class=fn><a href="#QVariant-o"><b>QVariant</b></a> ( const QTime & val )</li> <li class=fn><a href="#QVariant-p"><b>QVariant</b></a> ( const QDateTime & val )</li> <li class=fn><a href="#QVariant-q"><b>QVariant</b></a> ( const QByteArray & val )</li> <li class=fn><a href="#QVariant-r"><b>QVariant</b></a> ( const QBitArray & val )</li> <li class=fn><a href="#QVariant-s"><b>QVariant</b></a> ( const QKeySequence & val )</li> <li class=fn><a href="#QVariant-t"><b>QVariant</b></a> ( const QPen & val )</li> <li class=fn><a href="#QVariant-u"><b>QVariant</b></a> ( const QValueList<QVariant> & val )</li> <li class=fn><a href="#QVariant-v"><b>QVariant</b></a> ( const QMap<QString, QVariant> & val )</li> <li class=fn><a href="#QVariant-w"><b>QVariant</b></a> ( int val )</li> <li class=fn><a href="#QVariant-x"><b>QVariant</b></a> ( uint val )</li> <li class=fn><a href="#QVariant-y"><b>QVariant</b></a> ( Q_LLONG val )</li> <li class=fn><a href="#QVariant-z"><b>QVariant</b></a> ( Q_ULLONG val )</li> <li class=fn><a href="#QVariant-10"><b>QVariant</b></a> ( bool val, int )</li> <li class=fn><a href="#QVariant-11"><b>QVariant</b></a> ( double val )</li> <li class=fn><a href="#QVariant-12"><b>QVariant</b></a> ( QSizePolicy val )</li> <li class=fn>QVariant & <a href="#operator-eq"><b>operator=</b></a> ( const QVariant & variant )</li> <li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QVariant & v ) const</li> <li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const QVariant & v ) const</li> <li class=fn>Type <a href="#type"><b>type</b></a> () const</li> <li class=fn>const char * <a href="#typeName"><b>typeName</b></a> () const</li> <li class=fn>bool <a href="#canCast"><b>canCast</b></a> ( Type t ) const</li> <li class=fn>bool <a href="#cast"><b>cast</b></a> ( Type t )</li> <li class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</li> <li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li> <li class=fn>void <a href="#clear"><b>clear</b></a> ()</li> <li class=fn>const QString <a href="#toString"><b>toString</b></a> () const</li> <li class=fn>const QCString <a href="#toCString"><b>toCString</b></a> () const</li> <li class=fn>const QStringList <a href="#toStringList"><b>toStringList</b></a> () const</li> <li class=fn>const QFont <a href="#toFont"><b>toFont</b></a> () const</li> <li class=fn>const QPixmap <a href="#toPixmap"><b>toPixmap</b></a> () const</li> <li class=fn>const QImage <a href="#toImage"><b>toImage</b></a> () const</li> <li class=fn>const QBrush <a href="#toBrush"><b>toBrush</b></a> () const</li> <li class=fn>const QPoint <a href="#toPoint"><b>toPoint</b></a> () const</li> <li class=fn>const QRect <a href="#toRect"><b>toRect</b></a> () const</li> <li class=fn>const QSize <a href="#toSize"><b>toSize</b></a> () const</li> <li class=fn>const QColor <a href="#toColor"><b>toColor</b></a> () const</li> <li class=fn>const QPalette <a href="#toPalette"><b>toPalette</b></a> () const</li> <li class=fn>const QColorGroup <a href="#toColorGroup"><b>toColorGroup</b></a> () const</li> <li class=fn>const QIconSet <a href="#toIconSet"><b>toIconSet</b></a> () const</li> <li class=fn>const QPointArray <a href="#toPointArray"><b>toPointArray</b></a> () const</li> <li class=fn>const QBitmap <a href="#toBitmap"><b>toBitmap</b></a> () const</li> <li class=fn>const QRegion <a href="#toRegion"><b>toRegion</b></a> () const</li> <li class=fn>const QCursor <a href="#toCursor"><b>toCursor</b></a> () const</li> <li class=fn>const QDate <a href="#toDate"><b>toDate</b></a> () const</li> <li class=fn>const QTime <a href="#toTime"><b>toTime</b></a> () const</li> <li class=fn>const QDateTime <a href="#toDateTime"><b>toDateTime</b></a> () const</li> <li class=fn>const QByteArray <a href="#toByteArray"><b>toByteArray</b></a> () const</li> <li class=fn>const QBitArray <a href="#toBitArray"><b>toBitArray</b></a> () const</li> <li class=fn>const QKeySequence <a href="#toKeySequence"><b>toKeySequence</b></a> () const</li> <li class=fn>const QPen <a href="#toPen"><b>toPen</b></a> () const</li> <li class=fn>int <a href="#toInt"><b>toInt</b></a> ( bool * ok = 0 ) const</li> <li class=fn>uint <a href="#toUInt"><b>toUInt</b></a> ( bool * ok = 0 ) const</li> <li class=fn>Q_LLONG <a href="#toLongLong"><b>toLongLong</b></a> ( bool * ok = 0 ) const</li> <li class=fn>Q_ULLONG <a href="#toULongLong"><b>toULongLong</b></a> ( bool * ok = 0 ) const</li> <li class=fn>bool <a href="#toBool"><b>toBool</b></a> () const</li> <li class=fn>double <a href="#toDouble"><b>toDouble</b></a> ( bool * ok = 0 ) const</li> <li class=fn>const QValueList<QVariant> <a href="#toList"><b>toList</b></a> () const</li> <li class=fn>const QMap<QString, QVariant> <a href="#toMap"><b>toMap</b></a> () const</li> <li class=fn>QSizePolicy <a href="#toSizePolicy"><b>toSizePolicy</b></a> () const</li> <li class=fn>QValueListConstIterator<QString> stringListBegin () const <em>(obsolete)</em></li> <li class=fn>QValueListConstIterator<QString> stringListEnd () const <em>(obsolete)</em></li> <li class=fn>QValueListConstIterator<QVariant> listBegin () const <em>(obsolete)</em></li> <li class=fn>QValueListConstIterator<QVariant> listEnd () const <em>(obsolete)</em></li> <li class=fn>QMapConstIterator<QString, QVariant> mapBegin () const <em>(obsolete)</em></li> <li class=fn>QMapConstIterator<QString, QVariant> mapEnd () const <em>(obsolete)</em></li> <li class=fn>QMapConstIterator<QString, QVariant> mapFind ( const QString & key ) const <em>(obsolete)</em></li> <li class=fn>QString & <a href="#asString"><b>asString</b></a> ()</li> <li class=fn>QCString & <a href="#asCString"><b>asCString</b></a> ()</li> <li class=fn>QStringList & <a href="#asStringList"><b>asStringList</b></a> ()</li> <li class=fn>QFont & <a href="#asFont"><b>asFont</b></a> ()</li> <li class=fn>QPixmap & <a href="#asPixmap"><b>asPixmap</b></a> ()</li> <li class=fn>QImage & <a href="#asImage"><b>asImage</b></a> ()</li> <li class=fn>QBrush & <a href="#asBrush"><b>asBrush</b></a> ()</li> <li class=fn>QPoint & <a href="#asPoint"><b>asPoint</b></a> ()</li> <li class=fn>QRect & <a href="#asRect"><b>asRect</b></a> ()</li> <li class=fn>QSize & <a href="#asSize"><b>asSize</b></a> ()</li> <li class=fn>QColor & <a href="#asColor"><b>asColor</b></a> ()</li> <li class=fn>QPalette & <a href="#asPalette"><b>asPalette</b></a> ()</li> <li class=fn>QColorGroup & <a href="#asColorGroup"><b>asColorGroup</b></a> ()</li> <li class=fn>QIconSet & <a href="#asIconSet"><b>asIconSet</b></a> ()</li> <li class=fn>QPointArray & <a href="#asPointArray"><b>asPointArray</b></a> ()</li> <li class=fn>QBitmap & <a href="#asBitmap"><b>asBitmap</b></a> ()</li> <li class=fn>QRegion & <a href="#asRegion"><b>asRegion</b></a> ()</li> <li class=fn>QCursor & <a href="#asCursor"><b>asCursor</b></a> ()</li> <li class=fn>QDate & <a href="#asDate"><b>asDate</b></a> ()</li> <li class=fn>QTime & <a href="#asTime"><b>asTime</b></a> ()</li> <li class=fn>QDateTime & <a href="#asDateTime"><b>asDateTime</b></a> ()</li> <li class=fn>QByteArray & <a href="#asByteArray"><b>asByteArray</b></a> ()</li> <li class=fn>QBitArray & <a href="#asBitArray"><b>asBitArray</b></a> ()</li> <li class=fn>QKeySequence & <a href="#asKeySequence"><b>asKeySequence</b></a> ()</li> <li class=fn>QPen & <a href="#asPen"><b>asPen</b></a> ()</li> <li class=fn>int & <a href="#asInt"><b>asInt</b></a> ()</li> <li class=fn>uint & <a href="#asUInt"><b>asUInt</b></a> ()</li> <li class=fn>Q_LLONG & <a href="#asLongLong"><b>asLongLong</b></a> ()</li> <li class=fn>Q_ULLONG & <a href="#asULongLong"><b>asULongLong</b></a> ()</li> <li class=fn>bool & <a href="#asBool"><b>asBool</b></a> ()</li> <li class=fn>double & <a href="#asDouble"><b>asDouble</b></a> ()</li> <li class=fn>QValueList<QVariant> & <a href="#asList"><b>asList</b></a> ()</li> <li class=fn>QMap<QString, QVariant> & <a href="#asMap"><b>asMap</b></a> ()</li> <li class=fn>QSizePolicy & <a href="#asSizePolicy"><b>asSizePolicy</b></a> ()</li> </ul> <h2>Static Public Members</h2> <ul> <li class=fn>const char * <a href="#typeToName"><b>typeToName</b></a> ( Type typ )</li> <li class=fn>Type <a href="#nameToType"><b>nameToType</b></a> ( const char * name )</li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> The QVariant class acts like a union for the most common Qt data types. <p> <p> Because C++ forbids unions from including types that have non-default constructors or destructors, most interesting Qt classes cannot be used in unions. Without QVariant, this would be a problem for <a href="qobject.html#property">QObject::property</a>() and for database work, etc. <p> A QVariant object holds a single value of a single <a href="#type">type</a>() at a time. (Some type()s are multi-valued, for example a string list.) You can find out what type, T, the variant holds, convert it to a different type using one of the asT() functions, e.g. <a href="#asSize">asSize</a>(), get its value using one of the toT() functions, e.g. <a href="#toSize">toSize</a>(), and check whether the type can be converted to a particular type using <a href="#canCast">canCast</a>(). <p> The methods named toT() (for any supported T, see the <a href="#Type-enum">Type</a> documentation for a list) are const. If you ask for the stored type, they return a copy of the stored object. If you ask for a type that can be generated from the stored type, toT() copies and converts and leaves the object itself unchanged. If you ask for a type that cannot be generated from the stored type, the result depends on the type (see the function documentation for details). <p> Note that three data types supported by QVariant are <a href="shclass.html#explicitly-shared">explicitly shared</a>, namely <a href="qimage.html">QImage</a>, <a href="qpointarray.html">QPointArray</a>, and <a href="qcstring.html">QCString</a>, and in these cases the toT() methods return a <a href="shclass.html#shallow-copy">shallow copy</a>. In almost all cases you must make a <a href="shclass.html#deep-copy">deep copy</a> of the returned values before modifying them. <p> The asT() functions are not const. They do conversion like the toT() methods, set the variant to hold the converted value, and return a reference to the new contents of the variant. <p> Here is some example code to demonstrate the use of QVariant: <p> <pre> <a href="qdatastream.html">QDataStream</a> out(...); QVariant v(123); // The variant now contains an int int x = v.<a href="#toInt">toInt</a>(); // x = 123 out << v; // Writes a type tag and an int to out v = <a href="#QVariant">QVariant</a>("hello"); // The variant now contains a QCString v = <a href="#QVariant">QVariant</a>(tr("hello"));// The variant now contains a QString int y = v.<a href="#toInt">toInt</a>(); // y = 0 since v cannot be converted to an int <a href="qstring.html">QString</a> s = v.<a href="#toString">toString</a>(); // s = tr("hello") (see QObject::tr()) out << v; // Writes a type tag and a QString to out ... <a href="qdatastream.html">QDataStream</a> in(...); // (opening the previously written stream) in >> v; // Reads an Int variant int z = v.<a href="#toInt">toInt</a>(); // z = 123 <a href="qapplication.html#qDebug">qDebug</a>("Type is %s", // prints "Type is int" v.<a href="#typeName">typeName</a>()); v.<a href="#asInt">asInt</a>() += 100; // The variant now hold the value 223. v = <a href="#QVariant">QVariant</a>( QStringList() ); v.<a href="#asStringList">asStringList</a>().append( "Hello" ); </pre> <p> You can even store <a href="qvaluelist.html">QValueList</a><QVariant>s and <a href="qmap.html">QMap</a><QString,QVariant>s in a variant, so you can easily construct arbitrarily complex data structures of arbitrary types. This is very powerful and versatile, but may prove less memory and speed efficient than storing specific types in standard data structures. <p> QVariant also supports the notion of NULL values, where you have a defined type with no value set. <pre> QVariant x, y( QString() ), z( QString("") ); x.<a href="#asInt">asInt</a>(); // x.<a href="#isNull">isNull</a>() == TRUE, y.isNull() == TRUE, z.isNull() == FALSE </pre> <p> See the <a href="collection.html">Collection Classes</a>. <p>See also <a href="misc.html">Miscellaneous Classes</a> and <a href="objectmodel.html">Object Model</a>. <hr><h2>Member Type Documentation</h2> <h3 class=fn><a name="Type-enum"></a>QVariant::Type</h3> <p> This enum type defines the types of variable that a QVariant can contain. <ul> <li><tt>QVariant::Invalid</tt> - no type <li><tt>QVariant::BitArray</tt> - a <a href="qbitarray.html">QBitArray</a> <li><tt>QVariant::ByteArray</tt> - a <a href="qbytearray.html">QByteArray</a> <li><tt>QVariant::Bitmap</tt> - a <a href="qbitmap.html">QBitmap</a> <li><tt>QVariant::Bool</tt> - a bool <li><tt>QVariant::Brush</tt> - a <a href="qbrush.html">QBrush</a> <li><tt>QVariant::Color</tt> - a <a href="qcolor.html">QColor</a> <li><tt>QVariant::ColorGroup</tt> - a <a href="qcolorgroup.html">QColorGroup</a> <li><tt>QVariant::Cursor</tt> - a <a href="qcursor.html">QCursor</a> <li><tt>QVariant::Date</tt> - a <a href="qdate.html">QDate</a> <li><tt>QVariant::DateTime</tt> - a <a href="qdatetime.html">QDateTime</a> <li><tt>QVariant::Double</tt> - a double <li><tt>QVariant::Font</tt> - a <a href="qfont.html">QFont</a> <li><tt>QVariant::IconSet</tt> - a <a href="qiconset.html">QIconSet</a> <li><tt>QVariant::Image</tt> - a <a href="qimage.html">QImage</a> <li><tt>QVariant::Int</tt> - an int <li><tt>QVariant::KeySequence</tt> - a <a href="qkeysequence.html">QKeySequence</a> <li><tt>QVariant::List</tt> - a <a href="qvaluelist.html">QValueList</a><QVariant> <li><tt>QVariant::LongLong</tt> - a long long <li><tt>QVariant::ULongLong</tt> - an unsigned long long <li><tt>QVariant::Map</tt> - a <a href="qmap.html">QMap</a><QString,QVariant> <li><tt>QVariant::Palette</tt> - a <a href="qpalette.html">QPalette</a> <li><tt>QVariant::Pen</tt> - a <a href="qpen.html">QPen</a> <li><tt>QVariant::Pixmap</tt> - a <a href="qpixmap.html">QPixmap</a> <li><tt>QVariant::Point</tt> - a <a href="qpoint.html">QPoint</a> <li><tt>QVariant::PointArray</tt> - a <a href="qpointarray.html">QPointArray</a> <li><tt>QVariant::Rect</tt> - a <a href="qrect.html">QRect</a> <li><tt>QVariant::Region</tt> - a <a href="qregion.html">QRegion</a> <li><tt>QVariant::Size</tt> - a <a href="qsize.html">QSize</a> <li><tt>QVariant::SizePolicy</tt> - a <a href="qsizepolicy.html">QSizePolicy</a> <li><tt>QVariant::String</tt> - a <a href="qstring.html">QString</a> <li><tt>QVariant::CString</tt> - a <a href="qcstring.html">QCString</a> <li><tt>QVariant::StringList</tt> - a <a href="qstringlist.html">QStringList</a> <li><tt>QVariant::Time</tt> - a <a href="qtime.html">QTime</a> <li><tt>QVariant::UInt</tt> - an unsigned int </ul><p> Note that Qt's definition of bool depends on the compiler. <a href="qglobal-h.html">qglobal.h</a> has the system-dependent definition of bool. <hr><h2>Member Function Documentation</h2> <h3 class=fn><a name="QVariant"></a>QVariant::QVariant () </h3> Constructs an invalid variant. <h3 class=fn><a name="QVariant-10"></a>QVariant::QVariant ( bool val, int ) </h3> Constructs a new variant with a boolean value, <em>val</em>. The integer argument is a dummy, necessary for compatibility with some compilers. <h3 class=fn><a name="QVariant-11"></a>QVariant::QVariant ( double val ) </h3> Constructs a new variant with a floating point value, <em>val</em>. <h3 class=fn><a name="QVariant-12"></a>QVariant::QVariant ( <a href="qsizepolicy.html">QSizePolicy</a> val ) </h3> Constructs a new variant with a size policy value, <em>val</em>. <h3 class=fn><a name="QVariant-2"></a>QVariant::QVariant ( const <a href="qvariant.html">QVariant</a> & p ) </h3> Constructs a copy of the variant, <em>p</em>, passed as the argument to this constructor. Usually this is a <a href="shclass.html#deep-copy">deep copy</a>, but a <a href="shclass.html#shallow-copy">shallow copy</a> is made if the stored data type is <a href="shclass.html#explicitly-shared">explicitly shared</a>, as e.g. <a href="qimage.html">QImage</a> is. <h3 class=fn><a name="QVariant-3"></a>QVariant::QVariant ( <a href="qdatastream.html">QDataStream</a> & s ) </h3> Reads the variant from the data stream, <em>s</em>. <h3 class=fn><a name="QVariant-4"></a>QVariant::QVariant ( const <a href="qstring.html">QString</a> & val ) </h3> Constructs a new variant with a string value, <em>val</em>. <h3 class=fn><a name="QVariant-5"></a>QVariant::QVariant ( const <a href="qcstring.html">QCString</a> & val ) </h3> Constructs a new variant with a C-string value, <em>val</em>. <p> If you want to modify the <a href="qcstring.html">QCString</a> after you've passed it to this constructor, we recommend passing a <a href="shclass.html#deep-copy">deep copy</a> (see <a href="qcstring.html#copy">QCString::copy</a>()). <h3 class=fn><a name="QVariant-6"></a>QVariant::QVariant ( const char * val ) </h3> Constructs a new variant with a C-string value of <em>val</em> if <em>val</em> is non-null. The variant creates a <a href="shclass.html#deep-copy">deep copy</a> of <em>val</em>. <p> If <em>val</em> is null, the resulting variant has type Invalid. <h3 class=fn><a name="QVariant-7"></a>QVariant::QVariant ( const <a href="qstringlist.html">QStringList</a> & val ) </h3> Constructs a new variant with a string list value, <em>val</em>. <h3 class=fn><a name="QVariant-8"></a>QVariant::QVariant ( const <a href="qfont.html">QFont</a> & val ) </h3> Constructs a new variant with a font value, <em>val</em>. <h3 class=fn><a name="QVariant-9"></a>QVariant::QVariant ( const <a href="qpixmap.html">QPixmap</a> & val ) </h3> Constructs a new variant with a pixmap value, <em>val</em>. <h3 class=fn><a name="QVariant-a"></a>QVariant::QVariant ( const <a href="qimage.html">QImage</a> & val ) </h3> Constructs a new variant with an image value, <em>val</em>. <p> Because <a href="qimage.html">QImage</a> is <a href="shclass.html#explicitly-shared">explicitly shared</a>, you may need to pass a <a href="shclass.html#deep-copy">deep copy</a> to the variant using <a href="qimage.html#copy">QImage::copy</a>(), e.g. if you intend changing the image you've passed later on. <h3 class=fn><a name="QVariant-b"></a>QVariant::QVariant ( const <a href="qbrush.html">QBrush</a> & val ) </h3> Constructs a new variant with a brush value, <em>val</em>. <h3 class=fn><a name="QVariant-c"></a>QVariant::QVariant ( const <a href="qpoint.html">QPoint</a> & val ) </h3> Constructs a new variant with a point value, <em>val</em>. <h3 class=fn><a name="QVariant-d"></a>QVariant::QVariant ( const <a href="qrect.html">QRect</a> & val ) </h3> Constructs a new variant with a rect value, <em>val</em>. <h3 class=fn><a name="QVariant-e"></a>QVariant::QVariant ( const <a href="qsize.html">QSize</a> & val ) </h3> Constructs a new variant with a size value, <em>val</em>. <h3 class=fn><a name="QVariant-f"></a>QVariant::QVariant ( const <a href="qcolor.html">QColor</a> & val ) </h3> Constructs a new variant with a color value, <em>val</em>. <h3 class=fn><a name="QVariant-g"></a>QVariant::QVariant ( const <a href="qpalette.html">QPalette</a> & val ) </h3> Constructs a new variant with a color palette value, <em>val</em>. <h3 class=fn><a name="QVariant-h"></a>QVariant::QVariant ( const <a href="qcolorgroup.html">QColorGroup</a> & val ) </h3> Constructs a new variant with a color group value, <em>val</em>. <h3 class=fn><a name="QVariant-i"></a>QVariant::QVariant ( const <a href="qiconset.html">QIconSet</a> & val ) </h3> Constructs a new variant with an icon set value, <em>val</em>. <h3 class=fn><a name="QVariant-j"></a>QVariant::QVariant ( const <a href="qpointarray.html">QPointArray</a> & val ) </h3> Constructs a new variant with a point array value, <em>val</em>. <p> Because <a href="qpointarray.html">QPointArray</a> is <a href="shclass.html#explicitly-shared">explicitly shared</a>, you may need to pass a <a href="shclass.html#deep-copy">deep copy</a> to the variant using <a href="qpointarray.html#copy">QPointArray::copy</a>(), e.g. if you intend changing the point array you've passed later on. <h3 class=fn><a name="QVariant-k"></a>QVariant::QVariant ( const <a href="qregion.html">QRegion</a> & val ) </h3> Constructs a new variant with a region value, <em>val</em>. <h3 class=fn><a name="QVariant-l"></a>QVariant::QVariant ( const <a href="qbitmap.html">QBitmap</a> & val ) </h3> Constructs a new variant with a bitmap value, <em>val</em>. <h3 class=fn><a name="QVariant-m"></a>QVariant::QVariant ( const <a href="qcursor.html">QCursor</a> & val ) </h3> Constructs a new variant with a cursor value, <em>val</em>. <h3 class=fn><a name="QVariant-n"></a>QVariant::QVariant ( const <a href="qdate.html">QDate</a> & val ) </h3> Constructs a new variant with a date value, <em>val</em>. <h3 class=fn><a name="QVariant-o"></a>QVariant::QVariant ( const <a href="qtime.html">QTime</a> & val ) </h3> Constructs a new variant with a time value, <em>val</em>. <h3 class=fn><a name="QVariant-p"></a>QVariant::QVariant ( const <a href="qdatetime.html">QDateTime</a> & val ) </h3> Constructs a new variant with a date/time value, <em>val</em>. <h3 class=fn><a name="QVariant-q"></a>QVariant::QVariant ( const <a href="qbytearray.html">QByteArray</a> & val ) </h3> Constructs a new variant with a bytearray value, <em>val</em>. <h3 class=fn><a name="QVariant-r"></a>QVariant::QVariant ( const <a href="qbitarray.html">QBitArray</a> & val ) </h3> Constructs a new variant with a bitarray value, <em>val</em>. <h3 class=fn><a name="QVariant-s"></a>QVariant::QVariant ( const <a href="qkeysequence.html">QKeySequence</a> & val ) </h3> Constructs a new variant with a key sequence value, <em>val</em>. <h3 class=fn><a name="QVariant-t"></a>QVariant::QVariant ( const <a href="qpen.html">QPen</a> & val ) </h3> Constructs a new variant with a pen value, <em>val</em>. <h3 class=fn><a name="QVariant-u"></a>QVariant::QVariant ( const <a href="qvaluelist.html">QValueList</a><QVariant> & val ) </h3> Constructs a new variant with a list value, <em>val</em>. <h3 class=fn><a name="QVariant-v"></a>QVariant::QVariant ( const <a href="qmap.html">QMap</a><QString, QVariant> & val ) </h3> Constructs a new variant with a map of QVariants, <em>val</em>. <h3 class=fn><a name="QVariant-w"></a>QVariant::QVariant ( int val ) </h3> Constructs a new variant with an integer value, <em>val</em>. <h3 class=fn><a name="QVariant-x"></a>QVariant::QVariant ( uint val ) </h3> Constructs a new variant with an unsigned integer value, <em>val</em>. <h3 class=fn><a name="QVariant-y"></a>QVariant::QVariant ( Q_LLONG val ) </h3> Constructs a new variant with a long long integer value, <em>val</em>. <h3 class=fn><a name="QVariant-z"></a>QVariant::QVariant ( Q_ULLONG val ) </h3> Constructs a new variant with an unsigned long long integer value, <em>val</em>. <h3 class=fn><a name="~QVariant"></a>QVariant::~QVariant () </h3> Destroys the QVariant and the contained object. <p> Note that subclasses that reimplement <a href="#clear">clear</a>() should reimplement the destructor to call clear(). This destructor calls clear(), but because it is the destructor, <a href="#clear">QVariant::clear</a>() is called rather than a subclass's clear(). <h3 class=fn><a href="qbitarray.html">QBitArray</a> & <a name="asBitArray"></a>QVariant::asBitArray () </h3> <p> Tries to convert the variant to hold a <a href="qbitarray.html">QBitArray</a> value. If that is not possible then the variant is set to an empty bitarray. <p> Returns a reference to the stored bitarray. <p> <p>See also <a href="#toBitArray">toBitArray</a>(). <h3 class=fn><a href="qbitmap.html">QBitmap</a> & <a name="asBitmap"></a>QVariant::asBitmap () </h3> <p> Tries to convert the variant to hold a bitmap value. If that is not possible the variant is set to a null bitmap. <p> Returns a reference to the stored bitmap. <p> <p>See also <a href="#toBitmap">toBitmap</a>(). <h3 class=fn>bool & <a name="asBool"></a>QVariant::asBool () </h3> Returns the variant's value as bool reference. <h3 class=fn><a href="qbrush.html">QBrush</a> & <a name="asBrush"></a>QVariant::asBrush () </h3> <p> Tries to convert the variant to hold a brush value. If that is not possible the variant is set to a default black brush. <p> Returns a reference to the stored brush. <p> <p>See also <a href="#toBrush">toBrush</a>(). <h3 class=fn><a href="qbytearray.html">QByteArray</a> & <a name="asByteArray"></a>QVariant::asByteArray () </h3> <p> Tries to convert the variant to hold a <a href="qbytearray.html">QByteArray</a> value. If that is not possible then the variant is set to an empty bytearray. <p> Returns a reference to the stored bytearray. <p> <p>See also <a href="#toByteArray">toByteArray</a>(). <h3 class=fn><a href="qcstring.html">QCString</a> & <a name="asCString"></a>QVariant::asCString () </h3> <p> Tries to convert the variant to hold a string value. If that is not possible the variant is set to an empty string. <p> Returns a reference to the stored string. <p> <p>See also <a href="#toCString">toCString</a>(). <h3 class=fn><a href="qcolor.html">QColor</a> & <a name="asColor"></a>QVariant::asColor () </h3> <p> Tries to convert the variant to hold a <a href="qcolor.html">QColor</a> value. If that is not possible the variant is set to an invalid color. <p> Returns a reference to the stored color. <p> <p>See also <a href="#toColor">toColor</a>() and <a href="qcolor.html#isValid">QColor::isValid</a>(). <h3 class=fn><a href="qcolorgroup.html">QColorGroup</a> & <a name="asColorGroup"></a>QVariant::asColorGroup () </h3> <p> Tries to convert the variant to hold a <a href="qcolorgroup.html">QColorGroup</a> value. If that is not possible the variant is set to a color group of all black colors. <p> Returns a reference to the stored color group. <p> <p>See also <a href="#toColorGroup">toColorGroup</a>(). <h3 class=fn><a href="qcursor.html">QCursor</a> & <a name="asCursor"></a>QVariant::asCursor () </h3> <p> Tries to convert the variant to hold a <a href="qcursor.html">QCursor</a> value. If that is not possible the variant is set to a default arrow cursor. <p> Returns a reference to the stored cursor. <p> <p>See also <a href="#toCursor">toCursor</a>(). <h3 class=fn><a href="qdate.html">QDate</a> & <a name="asDate"></a>QVariant::asDate () </h3> <p> Tries to convert the variant to hold a <a href="qdate.html">QDate</a> value. If that is not possible then the variant is set to an invalid date. <p> Returns a reference to the stored date. <p> <p>See also <a href="#toDate">toDate</a>(). <h3 class=fn><a href="qdatetime.html">QDateTime</a> & <a name="asDateTime"></a>QVariant::asDateTime () </h3> <p> Tries to convert the variant to hold a <a href="qdatetime.html">QDateTime</a> value. If that is not possible then the variant is set to an invalid date/time. <p> Returns a reference to the stored date/time. <p> <p>See also <a href="#toDateTime">toDateTime</a>(). <h3 class=fn>double & <a name="asDouble"></a>QVariant::asDouble () </h3> Returns the variant's value as double reference. <h3 class=fn><a href="qfont.html">QFont</a> & <a name="asFont"></a>QVariant::asFont () </h3> <p> Tries to convert the variant to hold a <a href="qfont.html">QFont</a>. If that is not possible the variant is set to the application's default font. <p> Returns a reference to the stored font. <p> <p>See also <a href="#toFont">toFont</a>(). <h3 class=fn><a href="qiconset.html">QIconSet</a> & <a name="asIconSet"></a>QVariant::asIconSet () </h3> <p> Tries to convert the variant to hold a <a href="qiconset.html">QIconSet</a> value. If that is not possible the variant is set to an empty iconset. <p> Returns a reference to the stored iconset. <p> <p>See also <a href="#toIconSet">toIconSet</a>(). <h3 class=fn><a href="qimage.html">QImage</a> & <a name="asImage"></a>QVariant::asImage () </h3> <p> Tries to convert the variant to hold an image value. If that is not possible the variant is set to a null image. <p> Returns a reference to the stored image. <p> <p>See also <a href="#toImage">toImage</a>(). <h3 class=fn>int & <a name="asInt"></a>QVariant::asInt () </h3> Returns the variant's value as int reference. <h3 class=fn><a href="qkeysequence.html">QKeySequence</a> & <a name="asKeySequence"></a>QVariant::asKeySequence () </h3> <p> Tries to convert the variant to hold a <a href="qkeysequence.html">QKeySequence</a> value. If that is not possible then the variant is set to an empty key sequence. <p> Returns a reference to the stored key sequence. <p> <p>See also <a href="#toKeySequence">toKeySequence</a>(). <h3 class=fn><a href="qvaluelist.html">QValueList</a><QVariant> & <a name="asList"></a>QVariant::asList () </h3> Returns the variant's value as variant list reference. <p> Note that if you want to iterate over the list, you should iterate over a copy, e.g. <pre> <a href="qvaluelist.html">QValueList</a><QVariant> list = myVariant.asList(); QValueList<QVariant>::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>(); while( it != list.<a href="qvaluelist.html#end">end</a>() ) { myProcessing( *it ); ++it; } </pre> <h3 class=fn>Q_LLONG & <a name="asLongLong"></a>QVariant::asLongLong () </h3> Returns the variant's value as long long reference. <h3 class=fn><a href="qmap.html">QMap</a><QString, QVariant> & <a name="asMap"></a>QVariant::asMap () </h3> Returns the variant's value as variant map reference. <p> Note that if you want to iterate over the map, you should iterate over a copy, e.g. <pre> <a href="qmap.html">QMap</a><QString, QVariant> map = myVariant.asMap(); QMap<QString, QVariant>::Iterator it = map.<a href="qmap.html#begin">begin</a>(); while( it != map.<a href="qmap.html#end">end</a>() ) { myProcessing( *it ); ++it; } </pre> <h3 class=fn><a href="qpalette.html">QPalette</a> & <a name="asPalette"></a>QVariant::asPalette () </h3> <p> Tries to convert the variant to hold a <a href="qpalette.html">QPalette</a> value. If that is not possible the variant is set to a palette of black colors. <p> Returns a reference to the stored palette. <p> <p>See also <a href="#toString">toString</a>(). <h3 class=fn><a href="qpen.html">QPen</a> & <a name="asPen"></a>QVariant::asPen () </h3> <p> Tries to convert the variant to hold a <a href="qpen.html">QPen</a> value. If that is not possible then the variant is set to an empty pen. <p> Returns a reference to the stored pen. <p> <p>See also <a href="#toPen">toPen</a>(). <h3 class=fn><a href="qpixmap.html">QPixmap</a> & <a name="asPixmap"></a>QVariant::asPixmap () </h3> <p> Tries to convert the variant to hold a pixmap value. If that is not possible the variant is set to a null pixmap. <p> Returns a reference to the stored pixmap. <p> <p>See also <a href="#toPixmap">toPixmap</a>(). <h3 class=fn><a href="qpoint.html">QPoint</a> & <a name="asPoint"></a>QVariant::asPoint () </h3> <p> Tries to convert the variant to hold a point value. If that is not possible the variant is set to a (0, 0) point. <p> Returns a reference to the stored point. <p> <p>See also <a href="#toPoint">toPoint</a>(). <h3 class=fn><a href="qpointarray.html">QPointArray</a> & <a name="asPointArray"></a>QVariant::asPointArray () </h3> <p> Tries to convert the variant to hold a <a href="qpointarray.html">QPointArray</a> value. If that is not possible the variant is set to an empty point array. <p> Returns a reference to the stored point array. <p> <p>See also <a href="#toPointArray">toPointArray</a>(). <h3 class=fn><a href="qrect.html">QRect</a> & <a name="asRect"></a>QVariant::asRect () </h3> <p> Tries to convert the variant to hold a rectangle value. If that is not possible the variant is set to an empty rectangle. <p> Returns a reference to the stored rectangle. <p> <p>See also <a href="#toRect">toRect</a>(). <h3 class=fn><a href="qregion.html">QRegion</a> & <a name="asRegion"></a>QVariant::asRegion () </h3> <p> Tries to convert the variant to hold a <a href="qregion.html">QRegion</a> value. If that is not possible the variant is set to a null region. <p> Returns a reference to the stored region. <p> <p>See also <a href="#toRegion">toRegion</a>(). <h3 class=fn><a href="qsize.html">QSize</a> & <a name="asSize"></a>QVariant::asSize () </h3> <p> Tries to convert the variant to hold a <a href="qsize.html">QSize</a> value. If that is not possible the variant is set to an invalid size. <p> Returns a reference to the stored size. <p> <p>See also <a href="#toSize">toSize</a>() and <a href="qsize.html#isValid">QSize::isValid</a>(). <h3 class=fn><a href="qsizepolicy.html">QSizePolicy</a> & <a name="asSizePolicy"></a>QVariant::asSizePolicy () </h3> <p> Tries to convert the variant to hold a <a href="qsizepolicy.html">QSizePolicy</a> value. If that fails, the variant is set to an arbitrary (valid) size policy. <h3 class=fn><a href="qstring.html">QString</a> & <a name="asString"></a>QVariant::asString () </h3> <p> Tries to convert the variant to hold a string value. If that is not possible the variant is set to an empty string. <p> Returns a reference to the stored string. <p> <p>See also <a href="#toString">toString</a>(). <h3 class=fn><a href="qstringlist.html">QStringList</a> & <a name="asStringList"></a>QVariant::asStringList () </h3> <p> Tries to convert the variant to hold a <a href="qstringlist.html">QStringList</a> value. If that is not possible the variant is set to an empty string list. <p> Returns a reference to the stored string list. <p> Note that if you want to iterate over the list, you should iterate over a copy, e.g. <pre> <a href="qstringlist.html">QStringList</a> list = myVariant.asStringList(); QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>(); while( it != list.<a href="qvaluelist.html#end">end</a>() ) { myProcessing( *it ); ++it; } </pre> <p> <p>See also <a href="#toStringList">toStringList</a>(). <h3 class=fn><a href="qtime.html">QTime</a> & <a name="asTime"></a>QVariant::asTime () </h3> <p> Tries to convert the variant to hold a <a href="qtime.html">QTime</a> value. If that is not possible then the variant is set to an invalid time. <p> Returns a reference to the stored time. <p> <p>See also <a href="#toTime">toTime</a>(). <h3 class=fn>uint & <a name="asUInt"></a>QVariant::asUInt () </h3> Returns the variant's value as unsigned int reference. <h3 class=fn>Q_ULLONG & <a name="asULongLong"></a>QVariant::asULongLong () </h3> Returns the variant's value as unsigned long long reference. <h3 class=fn>bool <a name="canCast"></a>QVariant::canCast ( <a href="qvariant.html#Type-enum">Type</a> t ) const </h3> Returns TRUE if the variant's type can be cast to the requested type, <em>t</em>. Such casting is done automatically when calling the <a href="#toInt">toInt</a>(), <a href="#toBool">toBool</a>(), ... or <a href="#asInt">asInt</a>(), <a href="#asBool">asBool</a>(), ... methods. <p> The following casts are done automatically: <center><table cellpadding="4" cellspacing="2" border="0"> <tr bgcolor="#a2c511"> <th valign="top">Type <th valign="top">Automatically Cast To <tr bgcolor="#f0f0f0"> <td valign="top">Bool <td valign="top">Double, Int, UInt, LongLong, ULongLong, String, CString, ByteArray <tr bgcolor="#d0d0d0"> <td valign="top">Color <td valign="top">String. CString. ByteArray <tr bgcolor="#f0f0f0"> <td valign="top">Date <td valign="top">String, CString, ByteArray, DateTime <tr bgcolor="#d0d0d0"> <td valign="top">DateTime <td valign="top">String, CString, ByteArray, Date, Time <tr bgcolor="#f0f0f0"> <td valign="top">Double <td valign="top">String, CString, ByteArray, Int, Bool, UInt, LongLong, ULongLong <tr bgcolor="#d0d0d0"> <td valign="top">Font <td valign="top">String, CString, ByteArray <tr bgcolor="#f0f0f0"> <td valign="top">Int <td valign="top">String, CString, ByteArray, Double, Bool, UInt, LongLong, ULongLong, KeySequence <tr bgcolor="#d0d0d0"> <td valign="top">LongLong <td valign="top">String, CString, ByteArray, Double, Bool, UInt, LongLong, ULongLong, KeySequence <tr bgcolor="#f0f0f0"> <td valign="top">ULongLong <td valign="top">String, CString, ByteArray, Double, Bool, UInt, LongLong, ULongLong, KeySequence <tr bgcolor="#d0d0d0"> <td valign="top">List <td valign="top">StringList (if the list contains only strings or something that can be cast to a string) <tr bgcolor="#f0f0f0"> <td valign="top">String <td valign="top">CString, ByteArray, CString, Int, UInt, Bool, Double, Date, Time, DateTime, KeySequence, Font, Color <tr bgcolor="#d0d0d0"> <td valign="top">CString <td valign="top">String, ByteArray, Int, UInt, Bool, Double, Date, ULongLong, LongLong <tr bgcolor="#f0f0f0"> <td valign="top">ByteArray <td valign="top">String, CString, Int, UInt, Bool, Double, Date, ULongLong, LongLong <tr bgcolor="#d0d0d0"> <td valign="top">StringList <td valign="top">List <tr bgcolor="#f0f0f0"> <td valign="top">Time <td valign="top">String <tr bgcolor="#d0d0d0"> <td valign="top">Int <td valign="top">String, CString, ByteArray, Double, Bool, UInt, LongLong, ULongLong, KeySequence <tr bgcolor="#f0f0f0"> <td valign="top">KeySequence <td valign="top">String, CString, ByteArray, Int, UInt, LongLong, ULongLong </table></center> <h3 class=fn>bool <a name="cast"></a>QVariant::cast ( <a href="qvariant.html#Type-enum">Type</a> t ) </h3> Casts the variant to the requested type. If the cast cannot be done, the variant is set to the default value of the requested type (e.g. an empty string if the requested type <em>t</em> is QVariant::String, an empty point array if the requested type <em>t</em> is QVariant::PointArray, etc). Returns TRUE if the current type of the variant was successfully cast; otherwise returns FALSE. <p> <p>See also <a href="#canCast">canCast</a>(). <h3 class=fn>void <a name="clear"></a>QVariant::clear () </h3> Convert this variant to type Invalid and free up any resources used. <h3 class=fn>bool <a name="isNull"></a>QVariant::isNull () const </h3> Returns TRUE if this is a NULL variant, FALSE otherwise. <h3 class=fn>bool <a name="isValid"></a>QVariant::isValid () const </h3> <p> Returns TRUE if the storage type of this variant is not QVariant::Invalid; otherwise returns FALSE. <h3 class=fn><a href="qvaluelistconstiterator.html">QValueListConstIterator</a><QVariant> <a name="listBegin"></a>QVariant::listBegin () const </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Returns an iterator to the first item in the list if the variant's type is appropriate; otherwise returns a null iterator. <h3 class=fn><a href="qvaluelistconstiterator.html">QValueListConstIterator</a><QVariant> <a name="listEnd"></a>QVariant::listEnd () const </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Returns the end iterator for the list if the variant's type is appropriate; otherwise returns a null iterator. <h3 class=fn><a href="qmapconstiterator.html">QMapConstIterator</a><QString, QVariant> <a name="mapBegin"></a>QVariant::mapBegin () const </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Returns an iterator to the first item in the map, if the variant's type is appropriate; otherwise returns a null iterator. <h3 class=fn><a href="qmapconstiterator.html">QMapConstIterator</a><QString, QVariant> <a name="mapEnd"></a>QVariant::mapEnd () const </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Returns the end iterator for the map, if the variant's type is appropriate; otherwise returns a null iterator. <h3 class=fn><a href="qmapconstiterator.html">QMapConstIterator</a><QString, QVariant> <a name="mapFind"></a>QVariant::mapFind ( const <a href="qstring.html">QString</a> & key ) const </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Returns an iterator to the item in the map with <em>key</em> as key, if the variant's type is appropriate and <em>key</em> is a valid key; otherwise returns a null iterator. <h3 class=fn><a href="qvariant.html#Type-enum">Type</a> <a name="nameToType"></a>QVariant::nameToType ( const char * name )<tt> [static]</tt> </h3> Converts the string representation of the storage type given in <em>name</em>, to its enum representation. <p> If the string representation cannot be converted to any enum representation, the variant is set to <a href="#Type-enum">Invalid</a>. <h3 class=fn>bool <a name="operator!-eq"></a>QVariant::operator!= ( const <a href="qvariant.html">QVariant</a> & v ) const </h3> Compares this QVariant with <em>v</em> and returns TRUE if they are not equal; otherwise returns FALSE. <h3 class=fn><a href="qvariant.html">QVariant</a> & <a name="operator-eq"></a>QVariant::operator= ( const <a href="qvariant.html">QVariant</a> & variant ) </h3> Assigns the value of the variant <em>variant</em> to this variant. <p> This is a <a href="shclass.html#deep-copy">deep copy</a> of the variant, but note that if the variant holds an <a href="shclass.html#explicitly-shared">explicitly shared</a> type such as <a href="qimage.html">QImage</a>, a <a href="shclass.html#shallow-copy">shallow copy</a> is performed. <h3 class=fn>bool <a name="operator-eq-eq"></a>QVariant::operator== ( const <a href="qvariant.html">QVariant</a> & v ) const </h3> Compares this QVariant with <em>v</em> and returns TRUE if they are equal; otherwise returns FALSE. <h3 class=fn><a href="qvaluelistconstiterator.html">QValueListConstIterator</a><QString> <a name="stringListBegin"></a>QVariant::stringListBegin () const </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Returns an iterator to the first string in the list if the variant's type is StringList; otherwise returns a null iterator. <h3 class=fn><a href="qvaluelistconstiterator.html">QValueListConstIterator</a><QString> <a name="stringListEnd"></a>QVariant::stringListEnd () const </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Returns the end iterator for the list if the variant's type is StringList; otherwise returns a null iterator. <h3 class=fn>const <a href="qbitarray.html">QBitArray</a> <a name="toBitArray"></a>QVariant::toBitArray () const </h3> Returns the variant as a <a href="qbitarray.html">QBitArray</a> if the variant has <a href="#type">type</a>() BitArray; otherwise returns an empty bitarray. <p> <p>See also <a href="#asBitArray">asBitArray</a>(). <h3 class=fn>const <a href="qbitmap.html">QBitmap</a> <a name="toBitmap"></a>QVariant::toBitmap () const </h3> Returns the variant as a <a href="qbitmap.html">QBitmap</a> if the variant has <a href="#type">type</a>() Bitmap; otherwise returns a null QBitmap. <p> <p>See also <a href="#asBitmap">asBitmap</a>(). <h3 class=fn>bool <a name="toBool"></a>QVariant::toBool () const </h3> Returns the variant as a bool if the variant can be cast to Bool; otherWise returns FALSE. <p> Returns TRUE if the variant has a numeric type and its value is non-zero, or if the variant has type String, ByteArray or CString and its lower-case content is not empty, "0" or "false"; otherwise returns FALSE. <p> <p>See also <a href="#asBool">asBool</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn>const <a href="qbrush.html">QBrush</a> <a name="toBrush"></a>QVariant::toBrush () const </h3> Returns the variant as a <a href="qbrush.html">QBrush</a> if the variant has <a href="#type">type</a>() Brush; otherwise returns a default brush (with all black colors). <p> <p>See also <a href="#asBrush">asBrush</a>(). <h3 class=fn>const <a href="qbytearray.html">QByteArray</a> <a name="toByteArray"></a>QVariant::toByteArray () const </h3> Returns the variant as a <a href="qbytearray.html">QByteArray</a> if the variant can be cast to a ByteArray; otherwise returns an empty bytearray. <p> <p>See also <a href="#asByteArray">asByteArray</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn>const <a href="qcstring.html">QCString</a> <a name="toCString"></a>QVariant::toCString () const </h3> Returns the variant as a <a href="qcstring.html">QCString</a> if the variant can be cast to a CString; otherwise returns 0. <p> <p>See also <a href="#asCString">asCString</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn>const <a href="qcolor.html">QColor</a> <a name="toColor"></a>QVariant::toColor () const </h3> Returns the variant as a <a href="qcolor.html">QColor</a> if the variant can be cast to Color; otherwise returns an invalid color. <p> <p>See also <a href="#asColor">asColor</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn>const <a href="qcolorgroup.html">QColorGroup</a> <a name="toColorGroup"></a>QVariant::toColorGroup () const </h3> Returns the variant as a <a href="qcolorgroup.html">QColorGroup</a> if the variant has <a href="#type">type</a>() ColorGroup; otherwise returns a completely black color group. <p> <p>See also <a href="#asColorGroup">asColorGroup</a>(). <h3 class=fn>const <a href="qcursor.html">QCursor</a> <a name="toCursor"></a>QVariant::toCursor () const </h3> Returns the variant as a <a href="qcursor.html">QCursor</a> if the variant has <a href="#type">type</a>() Cursor; otherwise returns the default arrow cursor. <p> <p>See also <a href="#asCursor">asCursor</a>(). <h3 class=fn>const <a href="qdate.html">QDate</a> <a name="toDate"></a>QVariant::toDate () const </h3> Returns the variant as a <a href="qdate.html">QDate</a> if the variant can be cast to Date; otherwise returns an invalid date. <p> Note that if the <a href="#type">type</a>() is String, CString or ByteArray an invalid date will be returned if the string cannot be parsed as a Qt::ISODate format date. <p> <p>See also <a href="#asDate">asDate</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn>const <a href="qdatetime.html">QDateTime</a> <a name="toDateTime"></a>QVariant::toDateTime () const </h3> Returns the variant as a <a href="qdatetime.html">QDateTime</a> if the variant can be cast to DateTime; otherwise returns an invalid QDateTime. <p> Note that if the <a href="#type">type</a>() is String, CString or ByteArray an invalid QDateTime will be returned if the string cannot be parsed as a Qt::ISODate format date/time. <p> <p>See also <a href="#asDateTime">asDateTime</a>(). <h3 class=fn>double <a name="toDouble"></a>QVariant::toDouble ( bool * ok = 0 ) const </h3> Returns the variant as a double if the variant can be cast to Double; otherwise returns 0.0. <p> If <em>ok</em> is non-null: <em>*ok</em> is set to TRUE if the value could be converted to a double; otherwise <em>*ok</em> is set to FALSE. <p> <p>See also <a href="#asDouble">asDouble</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn>const <a href="qfont.html">QFont</a> <a name="toFont"></a>QVariant::toFont () const </h3> Returns the variant as a <a href="qfont.html">QFont</a> if the variant can be cast to Font; otherwise returns the application's default font. <p> <p>See also <a href="#asFont">asFont</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn>const <a href="qiconset.html">QIconSet</a> <a name="toIconSet"></a>QVariant::toIconSet () const </h3> Returns the variant as a <a href="qiconset.html">QIconSet</a> if the variant has <a href="#type">type</a>() IconSet; otherwise returns an icon set of null pixmaps. <p> <p>See also <a href="#asIconSet">asIconSet</a>(). <h3 class=fn>const <a href="qimage.html">QImage</a> <a name="toImage"></a>QVariant::toImage () const </h3> Returns the variant as a <a href="qimage.html">QImage</a> if the variant has <a href="#type">type</a>() Image; otherwise returns a null image. <p> <p>See also <a href="#asImage">asImage</a>(). <h3 class=fn>int <a name="toInt"></a>QVariant::toInt ( bool * ok = 0 ) const </h3> Returns the variant as an int if the variant can be cast to Int; otherwise returns 0. <p> If <em>ok</em> is non-null: <em>*ok</em> is set to TRUE if the value could be converted to an int; otherwise <em>*ok</em> is set to FALSE. <p> <p>See also <a href="#asInt">asInt</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn>const <a href="qkeysequence.html">QKeySequence</a> <a name="toKeySequence"></a>QVariant::toKeySequence () const </h3> Returns the variant as a <a href="qkeysequence.html">QKeySequence</a> if the variant can be cast to a KeySequence; otherwise returns an empty key sequence. <p> <p>See also <a href="#asKeySequence">asKeySequence</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn>const <a href="qvaluelist.html">QValueList</a><QVariant> <a name="toList"></a>QVariant::toList () const </h3> Returns the variant as a <a href="qvaluelist.html">QValueList</a><QVariant> if the variant has <a href="#type">type</a>() List or StringList; otherwise returns an empty list. <p> Note that if you want to iterate over the list, you should iterate over a copy, e.g. <pre> <a href="qvaluelist.html">QValueList</a><QVariant> list = myVariant.toList(); QValueList<QVariant>::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>(); while( it != list.<a href="qvaluelist.html#end">end</a>() ) { myProcessing( *it ); ++it; } </pre> <p> <p>See also <a href="#asList">asList</a>(). <h3 class=fn>Q_LLONG <a name="toLongLong"></a>QVariant::toLongLong ( bool * ok = 0 ) const </h3> Returns the variant as a long long int if the variant can be cast to LongLong; otherwise returns 0. <p> If <em>ok</em> is non-null: <em>*ok</em> is set to TRUE if the value could be converted to an int; otherwise <em>*ok</em> is set to FALSE. <p> <p>See also <a href="#asLongLong">asLongLong</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn>const <a href="qmap.html">QMap</a><QString, QVariant> <a name="toMap"></a>QVariant::toMap () const </h3> Returns the variant as a <a href="qmap.html">QMap</a><QString,QVariant> if the variant has <a href="#type">type</a>() Map; otherwise returns an empty map. <p> Note that if you want to iterate over the map, you should iterate over a copy, e.g. <pre> <a href="qmap.html">QMap</a><QString, QVariant> map = myVariant.toMap(); QMap<QString, QVariant>::Iterator it = map.<a href="qmap.html#begin">begin</a>(); while( it != map.<a href="qmap.html#end">end</a>() ) { myProcessing( *it ); ++it; } </pre> <p> <p>See also <a href="#asMap">asMap</a>(). <h3 class=fn>const <a href="qpalette.html">QPalette</a> <a name="toPalette"></a>QVariant::toPalette () const </h3> Returns the variant as a <a href="qpalette.html">QPalette</a> if the variant has <a href="#type">type</a>() Palette; otherwise returns a completely black palette. <p> <p>See also <a href="#asPalette">asPalette</a>(). <h3 class=fn>const <a href="qpen.html">QPen</a> <a name="toPen"></a>QVariant::toPen () const </h3> Returns the variant as a <a href="qpen.html">QPen</a> if the variant has <a href="#type">type</a>() Pen; otherwise returns an empty QPen. <p> <p>See also <a href="#asPen">asPen</a>(). <h3 class=fn>const <a href="qpixmap.html">QPixmap</a> <a name="toPixmap"></a>QVariant::toPixmap () const </h3> Returns the variant as a <a href="qpixmap.html">QPixmap</a> if the variant has <a href="#type">type</a>() Pixmap; otherwise returns a null pixmap. <p> <p>See also <a href="#asPixmap">asPixmap</a>(). <h3 class=fn>const <a href="qpoint.html">QPoint</a> <a name="toPoint"></a>QVariant::toPoint () const </h3> Returns the variant as a <a href="qpoint.html">QPoint</a> if the variant has <a href="#type">type</a>() Point; otherwise returns a point (0, 0). <p> <p>See also <a href="#asPoint">asPoint</a>(). <h3 class=fn>const <a href="qpointarray.html">QPointArray</a> <a name="toPointArray"></a>QVariant::toPointArray () const </h3> Returns the variant as a <a href="qpointarray.html">QPointArray</a> if the variant has <a href="#type">type</a>() PointArray; otherwise returns an empty QPointArray. <p> <p>See also <a href="#asPointArray">asPointArray</a>(). <h3 class=fn>const <a href="qrect.html">QRect</a> <a name="toRect"></a>QVariant::toRect () const </h3> Returns the variant as a <a href="qrect.html">QRect</a> if the variant has <a href="#type">type</a>() Rect; otherwise returns an empty rectangle. <p> <p>See also <a href="#asRect">asRect</a>(). <h3 class=fn>const <a href="qregion.html">QRegion</a> <a name="toRegion"></a>QVariant::toRegion () const </h3> Returns the variant as a <a href="qregion.html">QRegion</a> if the variant has <a href="#type">type</a>() Region; otherwise returns an empty QRegion. <p> <p>See also <a href="#asRegion">asRegion</a>(). <h3 class=fn>const <a href="qsize.html">QSize</a> <a name="toSize"></a>QVariant::toSize () const </h3> Returns the variant as a <a href="qsize.html">QSize</a> if the variant has <a href="#type">type</a>() Size; otherwise returns an invalid size. <p> <p>See also <a href="#asSize">asSize</a>(). <h3 class=fn><a href="qsizepolicy.html">QSizePolicy</a> <a name="toSizePolicy"></a>QVariant::toSizePolicy () const </h3> Returns the variant as a <a href="qsizepolicy.html">QSizePolicy</a> if the variant has <a href="#type">type</a>() SizePolicy; otherwise returns an undefined (but legal) size policy. <h3 class=fn>const <a href="qstring.html">QString</a> <a name="toString"></a>QVariant::toString () const </h3> Returns the variant as a <a href="qstring.html">QString</a> if the variant can be cast to String, otherwise returns <a href="qstring.html#QString-null">QString::null</a>. <p> <p>See also <a href="#asString">asString</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn>const <a href="qstringlist.html">QStringList</a> <a name="toStringList"></a>QVariant::toStringList () const </h3> Returns the variant as a <a href="qstringlist.html">QStringList</a> if the variant has <a href="#type">type</a>() StringList or List of a type that can be converted to <a href="qstring.html">QString</a>; otherwise returns an empty list. <p> Note that if you want to iterate over the list, you should iterate over a copy, e.g. <pre> <a href="qstringlist.html">QStringList</a> list = myVariant.toStringList(); QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>(); while( it != list.<a href="qvaluelist.html#end">end</a>() ) { myProcessing( *it ); ++it; } </pre> <p> <p>See also <a href="#asStringList">asStringList</a>(). <h3 class=fn>const <a href="qtime.html">QTime</a> <a name="toTime"></a>QVariant::toTime () const </h3> Returns the variant as a <a href="qtime.html">QTime</a> if the variant can be cast to Time; otherwise returns an invalid date. <p> Note that if the <a href="#type">type</a>() is String, CString or ByteArray an invalid time will be returned if the string cannot be parsed as a Qt::ISODate format time. <p> <p>See also <a href="#asTime">asTime</a>(). <h3 class=fn>uint <a name="toUInt"></a>QVariant::toUInt ( bool * ok = 0 ) const </h3> Returns the variant as an unsigned int if the variant can be cast to UInt; otherwise returns 0. <p> If <em>ok</em> is non-null: <em>*ok</em> is set to TRUE if the value could be converted to an unsigned int; otherwise <em>*ok</em> is set to FALSE. <p> <p>See also <a href="#asUInt">asUInt</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn>Q_ULLONG <a name="toULongLong"></a>QVariant::toULongLong ( bool * ok = 0 ) const </h3> Returns the variant as as an unsigned long long int if the variant can be cast to ULongLong; otherwise returns 0. <p> If <em>ok</em> is non-null: <em>*ok</em> is set to TRUE if the value could be converted to an int; otherwise <em>*ok</em> is set to FALSE. <p> <p>See also <a href="#asULongLong">asULongLong</a>() and <a href="#canCast">canCast</a>(). <h3 class=fn><a href="qvariant.html#Type-enum">Type</a> <a name="type"></a>QVariant::type () const </h3> <p> Returns the storage type of the value stored in the variant. Usually it's best to test with <a href="#canCast">canCast</a>() whether the variant can deliver the data type you are interested in. <h3 class=fn>const char * <a name="typeName"></a>QVariant::typeName () const </h3> Returns the name of the type stored in the variant. The returned strings describe the C++ datatype used to store the data: for example, "QFont", "QString", or "QValueList<QVariant>". An Invalid variant returns 0. <h3 class=fn>const char * <a name="typeToName"></a>QVariant::typeToName ( <a href="qvariant.html#Type-enum">Type</a> typ )<tt> [static]</tt> </h3> Converts the enum representation of the storage type, <em>typ</em>, to its string representation. <!-- eof --> <hr><p> This file is part of the <a href="index.html">Qt toolkit</a>. Copyright © 1995-2007 <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2007 <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> <td align=right><div align=right>Qt 3.3.8</div> </table></div></address></body> </html>