[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qvariant.cpp:353 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QVariant Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <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>
|
---|
| 33 |
|
---|
| 34 | <p>The QVariant class acts like a union for the most common Qt data types.
|
---|
| 35 | <a href="#details">More...</a>
|
---|
| 36 | <p><tt>#include <<a href="qvariant-h.html">qvariant.h</a>></tt>
|
---|
| 37 | <p><a href="qvariant-members.html">List of all member functions.</a>
|
---|
| 38 | <h2>Public Members</h2>
|
---|
| 39 | <ul>
|
---|
| 40 | <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>
|
---|
| 41 | <li class=fn><a href="#QVariant"><b>QVariant</b></a> ()</li>
|
---|
| 42 | <li class=fn><a href="#~QVariant"><b>~QVariant</b></a> ()</li>
|
---|
| 43 | <li class=fn><a href="#QVariant-2"><b>QVariant</b></a> ( const QVariant & p )</li>
|
---|
| 44 | <li class=fn><a href="#QVariant-3"><b>QVariant</b></a> ( QDataStream & s )</li>
|
---|
| 45 | <li class=fn><a href="#QVariant-4"><b>QVariant</b></a> ( const QString & val )</li>
|
---|
| 46 | <li class=fn><a href="#QVariant-5"><b>QVariant</b></a> ( const QCString & val )</li>
|
---|
| 47 | <li class=fn><a href="#QVariant-6"><b>QVariant</b></a> ( const char * val )</li>
|
---|
| 48 | <li class=fn><a href="#QVariant-7"><b>QVariant</b></a> ( const QStringList & val )</li>
|
---|
| 49 | <li class=fn><a href="#QVariant-8"><b>QVariant</b></a> ( const QFont & val )</li>
|
---|
| 50 | <li class=fn><a href="#QVariant-9"><b>QVariant</b></a> ( const QPixmap & val )</li>
|
---|
| 51 | <li class=fn><a href="#QVariant-a"><b>QVariant</b></a> ( const QImage & val )</li>
|
---|
| 52 | <li class=fn><a href="#QVariant-b"><b>QVariant</b></a> ( const QBrush & val )</li>
|
---|
| 53 | <li class=fn><a href="#QVariant-c"><b>QVariant</b></a> ( const QPoint & val )</li>
|
---|
| 54 | <li class=fn><a href="#QVariant-d"><b>QVariant</b></a> ( const QRect & val )</li>
|
---|
| 55 | <li class=fn><a href="#QVariant-e"><b>QVariant</b></a> ( const QSize & val )</li>
|
---|
| 56 | <li class=fn><a href="#QVariant-f"><b>QVariant</b></a> ( const QColor & val )</li>
|
---|
| 57 | <li class=fn><a href="#QVariant-g"><b>QVariant</b></a> ( const QPalette & val )</li>
|
---|
| 58 | <li class=fn><a href="#QVariant-h"><b>QVariant</b></a> ( const QColorGroup & val )</li>
|
---|
| 59 | <li class=fn><a href="#QVariant-i"><b>QVariant</b></a> ( const QIconSet & val )</li>
|
---|
| 60 | <li class=fn><a href="#QVariant-j"><b>QVariant</b></a> ( const QPointArray & val )</li>
|
---|
| 61 | <li class=fn><a href="#QVariant-k"><b>QVariant</b></a> ( const QRegion & val )</li>
|
---|
| 62 | <li class=fn><a href="#QVariant-l"><b>QVariant</b></a> ( const QBitmap & val )</li>
|
---|
| 63 | <li class=fn><a href="#QVariant-m"><b>QVariant</b></a> ( const QCursor & val )</li>
|
---|
| 64 | <li class=fn><a href="#QVariant-n"><b>QVariant</b></a> ( const QDate & val )</li>
|
---|
| 65 | <li class=fn><a href="#QVariant-o"><b>QVariant</b></a> ( const QTime & val )</li>
|
---|
| 66 | <li class=fn><a href="#QVariant-p"><b>QVariant</b></a> ( const QDateTime & val )</li>
|
---|
| 67 | <li class=fn><a href="#QVariant-q"><b>QVariant</b></a> ( const QByteArray & val )</li>
|
---|
| 68 | <li class=fn><a href="#QVariant-r"><b>QVariant</b></a> ( const QBitArray & val )</li>
|
---|
| 69 | <li class=fn><a href="#QVariant-s"><b>QVariant</b></a> ( const QKeySequence & val )</li>
|
---|
| 70 | <li class=fn><a href="#QVariant-t"><b>QVariant</b></a> ( const QPen & val )</li>
|
---|
| 71 | <li class=fn><a href="#QVariant-u"><b>QVariant</b></a> ( const QValueList<QVariant> & val )</li>
|
---|
| 72 | <li class=fn><a href="#QVariant-v"><b>QVariant</b></a> ( const QMap<QString, QVariant> & val )</li>
|
---|
| 73 | <li class=fn><a href="#QVariant-w"><b>QVariant</b></a> ( int val )</li>
|
---|
| 74 | <li class=fn><a href="#QVariant-x"><b>QVariant</b></a> ( uint val )</li>
|
---|
| 75 | <li class=fn><a href="#QVariant-y"><b>QVariant</b></a> ( Q_LLONG val )</li>
|
---|
| 76 | <li class=fn><a href="#QVariant-z"><b>QVariant</b></a> ( Q_ULLONG val )</li>
|
---|
| 77 | <li class=fn><a href="#QVariant-10"><b>QVariant</b></a> ( bool val, int )</li>
|
---|
| 78 | <li class=fn><a href="#QVariant-11"><b>QVariant</b></a> ( double val )</li>
|
---|
| 79 | <li class=fn><a href="#QVariant-12"><b>QVariant</b></a> ( QSizePolicy val )</li>
|
---|
| 80 | <li class=fn>QVariant & <a href="#operator-eq"><b>operator=</b></a> ( const QVariant & variant )</li>
|
---|
| 81 | <li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QVariant & v ) const</li>
|
---|
| 82 | <li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const QVariant & v ) const</li>
|
---|
| 83 | <li class=fn>Type <a href="#type"><b>type</b></a> () const</li>
|
---|
| 84 | <li class=fn>const char * <a href="#typeName"><b>typeName</b></a> () const</li>
|
---|
| 85 | <li class=fn>bool <a href="#canCast"><b>canCast</b></a> ( Type t ) const</li>
|
---|
| 86 | <li class=fn>bool <a href="#cast"><b>cast</b></a> ( Type t )</li>
|
---|
| 87 | <li class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</li>
|
---|
| 88 | <li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
|
---|
| 89 | <li class=fn>void <a href="#clear"><b>clear</b></a> ()</li>
|
---|
| 90 | <li class=fn>const QString <a href="#toString"><b>toString</b></a> () const</li>
|
---|
| 91 | <li class=fn>const QCString <a href="#toCString"><b>toCString</b></a> () const</li>
|
---|
| 92 | <li class=fn>const QStringList <a href="#toStringList"><b>toStringList</b></a> () const</li>
|
---|
| 93 | <li class=fn>const QFont <a href="#toFont"><b>toFont</b></a> () const</li>
|
---|
| 94 | <li class=fn>const QPixmap <a href="#toPixmap"><b>toPixmap</b></a> () const</li>
|
---|
| 95 | <li class=fn>const QImage <a href="#toImage"><b>toImage</b></a> () const</li>
|
---|
| 96 | <li class=fn>const QBrush <a href="#toBrush"><b>toBrush</b></a> () const</li>
|
---|
| 97 | <li class=fn>const QPoint <a href="#toPoint"><b>toPoint</b></a> () const</li>
|
---|
| 98 | <li class=fn>const QRect <a href="#toRect"><b>toRect</b></a> () const</li>
|
---|
| 99 | <li class=fn>const QSize <a href="#toSize"><b>toSize</b></a> () const</li>
|
---|
| 100 | <li class=fn>const QColor <a href="#toColor"><b>toColor</b></a> () const</li>
|
---|
| 101 | <li class=fn>const QPalette <a href="#toPalette"><b>toPalette</b></a> () const</li>
|
---|
| 102 | <li class=fn>const QColorGroup <a href="#toColorGroup"><b>toColorGroup</b></a> () const</li>
|
---|
| 103 | <li class=fn>const QIconSet <a href="#toIconSet"><b>toIconSet</b></a> () const</li>
|
---|
| 104 | <li class=fn>const QPointArray <a href="#toPointArray"><b>toPointArray</b></a> () const</li>
|
---|
| 105 | <li class=fn>const QBitmap <a href="#toBitmap"><b>toBitmap</b></a> () const</li>
|
---|
| 106 | <li class=fn>const QRegion <a href="#toRegion"><b>toRegion</b></a> () const</li>
|
---|
| 107 | <li class=fn>const QCursor <a href="#toCursor"><b>toCursor</b></a> () const</li>
|
---|
| 108 | <li class=fn>const QDate <a href="#toDate"><b>toDate</b></a> () const</li>
|
---|
| 109 | <li class=fn>const QTime <a href="#toTime"><b>toTime</b></a> () const</li>
|
---|
| 110 | <li class=fn>const QDateTime <a href="#toDateTime"><b>toDateTime</b></a> () const</li>
|
---|
| 111 | <li class=fn>const QByteArray <a href="#toByteArray"><b>toByteArray</b></a> () const</li>
|
---|
| 112 | <li class=fn>const QBitArray <a href="#toBitArray"><b>toBitArray</b></a> () const</li>
|
---|
| 113 | <li class=fn>const QKeySequence <a href="#toKeySequence"><b>toKeySequence</b></a> () const</li>
|
---|
| 114 | <li class=fn>const QPen <a href="#toPen"><b>toPen</b></a> () const</li>
|
---|
| 115 | <li class=fn>int <a href="#toInt"><b>toInt</b></a> ( bool * ok = 0 ) const</li>
|
---|
| 116 | <li class=fn>uint <a href="#toUInt"><b>toUInt</b></a> ( bool * ok = 0 ) const</li>
|
---|
| 117 | <li class=fn>Q_LLONG <a href="#toLongLong"><b>toLongLong</b></a> ( bool * ok = 0 ) const</li>
|
---|
| 118 | <li class=fn>Q_ULLONG <a href="#toULongLong"><b>toULongLong</b></a> ( bool * ok = 0 ) const</li>
|
---|
| 119 | <li class=fn>bool <a href="#toBool"><b>toBool</b></a> () const</li>
|
---|
| 120 | <li class=fn>double <a href="#toDouble"><b>toDouble</b></a> ( bool * ok = 0 ) const</li>
|
---|
| 121 | <li class=fn>const QValueList<QVariant> <a href="#toList"><b>toList</b></a> () const</li>
|
---|
| 122 | <li class=fn>const QMap<QString, QVariant> <a href="#toMap"><b>toMap</b></a> () const</li>
|
---|
| 123 | <li class=fn>QSizePolicy <a href="#toSizePolicy"><b>toSizePolicy</b></a> () const</li>
|
---|
| 124 | <li class=fn>QValueListConstIterator<QString> stringListBegin () const <em>(obsolete)</em></li>
|
---|
| 125 | <li class=fn>QValueListConstIterator<QString> stringListEnd () const <em>(obsolete)</em></li>
|
---|
| 126 | <li class=fn>QValueListConstIterator<QVariant> listBegin () const <em>(obsolete)</em></li>
|
---|
| 127 | <li class=fn>QValueListConstIterator<QVariant> listEnd () const <em>(obsolete)</em></li>
|
---|
| 128 | <li class=fn>QMapConstIterator<QString, QVariant> mapBegin () const <em>(obsolete)</em></li>
|
---|
| 129 | <li class=fn>QMapConstIterator<QString, QVariant> mapEnd () const <em>(obsolete)</em></li>
|
---|
| 130 | <li class=fn>QMapConstIterator<QString, QVariant> mapFind ( const QString & key ) const <em>(obsolete)</em></li>
|
---|
| 131 | <li class=fn>QString & <a href="#asString"><b>asString</b></a> ()</li>
|
---|
| 132 | <li class=fn>QCString & <a href="#asCString"><b>asCString</b></a> ()</li>
|
---|
| 133 | <li class=fn>QStringList & <a href="#asStringList"><b>asStringList</b></a> ()</li>
|
---|
| 134 | <li class=fn>QFont & <a href="#asFont"><b>asFont</b></a> ()</li>
|
---|
| 135 | <li class=fn>QPixmap & <a href="#asPixmap"><b>asPixmap</b></a> ()</li>
|
---|
| 136 | <li class=fn>QImage & <a href="#asImage"><b>asImage</b></a> ()</li>
|
---|
| 137 | <li class=fn>QBrush & <a href="#asBrush"><b>asBrush</b></a> ()</li>
|
---|
| 138 | <li class=fn>QPoint & <a href="#asPoint"><b>asPoint</b></a> ()</li>
|
---|
| 139 | <li class=fn>QRect & <a href="#asRect"><b>asRect</b></a> ()</li>
|
---|
| 140 | <li class=fn>QSize & <a href="#asSize"><b>asSize</b></a> ()</li>
|
---|
| 141 | <li class=fn>QColor & <a href="#asColor"><b>asColor</b></a> ()</li>
|
---|
| 142 | <li class=fn>QPalette & <a href="#asPalette"><b>asPalette</b></a> ()</li>
|
---|
| 143 | <li class=fn>QColorGroup & <a href="#asColorGroup"><b>asColorGroup</b></a> ()</li>
|
---|
| 144 | <li class=fn>QIconSet & <a href="#asIconSet"><b>asIconSet</b></a> ()</li>
|
---|
| 145 | <li class=fn>QPointArray & <a href="#asPointArray"><b>asPointArray</b></a> ()</li>
|
---|
| 146 | <li class=fn>QBitmap & <a href="#asBitmap"><b>asBitmap</b></a> ()</li>
|
---|
| 147 | <li class=fn>QRegion & <a href="#asRegion"><b>asRegion</b></a> ()</li>
|
---|
| 148 | <li class=fn>QCursor & <a href="#asCursor"><b>asCursor</b></a> ()</li>
|
---|
| 149 | <li class=fn>QDate & <a href="#asDate"><b>asDate</b></a> ()</li>
|
---|
| 150 | <li class=fn>QTime & <a href="#asTime"><b>asTime</b></a> ()</li>
|
---|
| 151 | <li class=fn>QDateTime & <a href="#asDateTime"><b>asDateTime</b></a> ()</li>
|
---|
| 152 | <li class=fn>QByteArray & <a href="#asByteArray"><b>asByteArray</b></a> ()</li>
|
---|
| 153 | <li class=fn>QBitArray & <a href="#asBitArray"><b>asBitArray</b></a> ()</li>
|
---|
| 154 | <li class=fn>QKeySequence & <a href="#asKeySequence"><b>asKeySequence</b></a> ()</li>
|
---|
| 155 | <li class=fn>QPen & <a href="#asPen"><b>asPen</b></a> ()</li>
|
---|
| 156 | <li class=fn>int & <a href="#asInt"><b>asInt</b></a> ()</li>
|
---|
| 157 | <li class=fn>uint & <a href="#asUInt"><b>asUInt</b></a> ()</li>
|
---|
| 158 | <li class=fn>Q_LLONG & <a href="#asLongLong"><b>asLongLong</b></a> ()</li>
|
---|
| 159 | <li class=fn>Q_ULLONG & <a href="#asULongLong"><b>asULongLong</b></a> ()</li>
|
---|
| 160 | <li class=fn>bool & <a href="#asBool"><b>asBool</b></a> ()</li>
|
---|
| 161 | <li class=fn>double & <a href="#asDouble"><b>asDouble</b></a> ()</li>
|
---|
| 162 | <li class=fn>QValueList<QVariant> & <a href="#asList"><b>asList</b></a> ()</li>
|
---|
| 163 | <li class=fn>QMap<QString, QVariant> & <a href="#asMap"><b>asMap</b></a> ()</li>
|
---|
| 164 | <li class=fn>QSizePolicy & <a href="#asSizePolicy"><b>asSizePolicy</b></a> ()</li>
|
---|
| 165 | </ul>
|
---|
| 166 | <h2>Static Public Members</h2>
|
---|
| 167 | <ul>
|
---|
| 168 | <li class=fn>const char * <a href="#typeToName"><b>typeToName</b></a> ( Type typ )</li>
|
---|
| 169 | <li class=fn>Type <a href="#nameToType"><b>nameToType</b></a> ( const char * name )</li>
|
---|
| 170 | </ul>
|
---|
| 171 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 172 |
|
---|
| 173 |
|
---|
| 174 | The QVariant class acts like a union for the most common Qt data types.
|
---|
| 175 | <p>
|
---|
| 176 |
|
---|
| 177 |
|
---|
| 178 | <p> Because C++ forbids unions from including types that have
|
---|
| 179 | non-default constructors or destructors, most interesting Qt
|
---|
| 180 | classes cannot be used in unions. Without QVariant, this would be
|
---|
| 181 | a problem for <a href="qobject.html#property">QObject::property</a>() and for database work, etc.
|
---|
| 182 | <p> A QVariant object holds a single value of a single <a href="#type">type</a>() at a
|
---|
| 183 | time. (Some type()s are multi-valued, for example a string list.)
|
---|
| 184 | You can find out what type, T, the variant holds, convert it to a
|
---|
| 185 | different type using one of the asT() functions, e.g. <a href="#asSize">asSize</a>(),
|
---|
| 186 | get its value using one of the toT() functions, e.g. <a href="#toSize">toSize</a>(), and
|
---|
| 187 | check whether the type can be converted to a particular type using
|
---|
| 188 | <a href="#canCast">canCast</a>().
|
---|
| 189 | <p> The methods named toT() (for any supported T, see the <a href="#Type-enum">Type</a>
|
---|
| 190 | documentation for a list) are const. If you ask for the stored
|
---|
| 191 | type, they return a copy of the stored object. If you ask for a
|
---|
| 192 | type that can be generated from the stored type, toT() copies and
|
---|
| 193 | converts and leaves the object itself unchanged. If you ask for a
|
---|
| 194 | type that cannot be generated from the stored type, the result
|
---|
| 195 | depends on the type (see the function documentation for details).
|
---|
| 196 | <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
|
---|
| 197 | cases the toT() methods return a <a href="shclass.html#shallow-copy">shallow copy</a>. In almost all cases
|
---|
| 198 | you must make a <a href="shclass.html#deep-copy">deep copy</a> of the returned values before modifying
|
---|
| 199 | them.
|
---|
| 200 | <p> The asT() functions are not const. They do conversion like the
|
---|
| 201 | toT() methods, set the variant to hold the converted value, and
|
---|
| 202 | return a reference to the new contents of the variant.
|
---|
| 203 | <p> Here is some example code to demonstrate the use of QVariant:
|
---|
| 204 | <p> <pre>
|
---|
| 205 | <a href="qdatastream.html">QDataStream</a> out(...);
|
---|
| 206 | QVariant v(123); // The variant now contains an int
|
---|
| 207 | int x = v.<a href="#toInt">toInt</a>(); // x = 123
|
---|
| 208 | out << v; // Writes a type tag and an int to out
|
---|
| 209 | v = <a href="#QVariant">QVariant</a>("hello"); // The variant now contains a QCString
|
---|
| 210 | v = <a href="#QVariant">QVariant</a>(tr("hello"));// The variant now contains a QString
|
---|
| 211 | int y = v.<a href="#toInt">toInt</a>(); // y = 0 since v cannot be converted to an int
|
---|
| 212 | <a href="qstring.html">QString</a> s = v.<a href="#toString">toString</a>(); // s = tr("hello") (see QObject::tr())
|
---|
| 213 | out << v; // Writes a type tag and a QString to out
|
---|
| 214 | ...
|
---|
| 215 | <a href="qdatastream.html">QDataStream</a> in(...); // (opening the previously written stream)
|
---|
| 216 | in >> v; // Reads an Int variant
|
---|
| 217 | int z = v.<a href="#toInt">toInt</a>(); // z = 123
|
---|
| 218 | <a href="qapplication.html#qDebug">qDebug</a>("Type is %s", // prints "Type is int"
|
---|
| 219 | v.<a href="#typeName">typeName</a>());
|
---|
| 220 | v.<a href="#asInt">asInt</a>() += 100; // The variant now hold the value 223.
|
---|
| 221 | v = <a href="#QVariant">QVariant</a>( QStringList() );
|
---|
| 222 | v.<a href="#asStringList">asStringList</a>().append( "Hello" );
|
---|
| 223 | </pre>
|
---|
| 224 |
|
---|
| 225 | <p> You can even store <a href="qvaluelist.html">QValueList</a><QVariant>s and
|
---|
| 226 | <a href="qmap.html">QMap</a><QString,QVariant>s in a variant, so you can easily construct
|
---|
| 227 | arbitrarily complex data structures of arbitrary types. This is
|
---|
| 228 | very powerful and versatile, but may prove less memory and speed
|
---|
| 229 | efficient than storing specific types in standard data structures.
|
---|
| 230 | <p> QVariant also supports the notion of NULL values, where you have a
|
---|
| 231 | defined type with no value set.
|
---|
| 232 | <pre>
|
---|
| 233 | QVariant x, y( QString() ), z( QString("") );
|
---|
| 234 | x.<a href="#asInt">asInt</a>();
|
---|
| 235 | // x.<a href="#isNull">isNull</a>() == TRUE, y.isNull() == TRUE, z.isNull() == FALSE
|
---|
| 236 | </pre>
|
---|
| 237 |
|
---|
| 238 | <p> See the <a href="collection.html">Collection Classes</a>.
|
---|
| 239 | <p>See also <a href="misc.html">Miscellaneous Classes</a> and <a href="objectmodel.html">Object Model</a>.
|
---|
| 240 |
|
---|
| 241 | <hr><h2>Member Type Documentation</h2>
|
---|
| 242 | <h3 class=fn><a name="Type-enum"></a>QVariant::Type</h3>
|
---|
| 243 |
|
---|
| 244 | <p> This enum type defines the types of variable that a QVariant can
|
---|
| 245 | contain.
|
---|
| 246 | <ul>
|
---|
| 247 | <li><tt>QVariant::Invalid</tt> - no type
|
---|
| 248 | <li><tt>QVariant::BitArray</tt> - a <a href="qbitarray.html">QBitArray</a>
|
---|
| 249 | <li><tt>QVariant::ByteArray</tt> - a <a href="qbytearray.html">QByteArray</a>
|
---|
| 250 | <li><tt>QVariant::Bitmap</tt> - a <a href="qbitmap.html">QBitmap</a>
|
---|
| 251 | <li><tt>QVariant::Bool</tt> - a bool
|
---|
| 252 | <li><tt>QVariant::Brush</tt> - a <a href="qbrush.html">QBrush</a>
|
---|
| 253 | <li><tt>QVariant::Color</tt> - a <a href="qcolor.html">QColor</a>
|
---|
| 254 | <li><tt>QVariant::ColorGroup</tt> - a <a href="qcolorgroup.html">QColorGroup</a>
|
---|
| 255 | <li><tt>QVariant::Cursor</tt> - a <a href="qcursor.html">QCursor</a>
|
---|
| 256 | <li><tt>QVariant::Date</tt> - a <a href="qdate.html">QDate</a>
|
---|
| 257 | <li><tt>QVariant::DateTime</tt> - a <a href="qdatetime.html">QDateTime</a>
|
---|
| 258 | <li><tt>QVariant::Double</tt> - a double
|
---|
| 259 | <li><tt>QVariant::Font</tt> - a <a href="qfont.html">QFont</a>
|
---|
| 260 | <li><tt>QVariant::IconSet</tt> - a <a href="qiconset.html">QIconSet</a>
|
---|
| 261 | <li><tt>QVariant::Image</tt> - a <a href="qimage.html">QImage</a>
|
---|
| 262 | <li><tt>QVariant::Int</tt> - an int
|
---|
| 263 | <li><tt>QVariant::KeySequence</tt> - a <a href="qkeysequence.html">QKeySequence</a>
|
---|
| 264 | <li><tt>QVariant::List</tt> - a <a href="qvaluelist.html">QValueList</a><QVariant>
|
---|
| 265 | <li><tt>QVariant::LongLong</tt> - a long long
|
---|
| 266 | <li><tt>QVariant::ULongLong</tt> - an unsigned long long
|
---|
| 267 | <li><tt>QVariant::Map</tt> - a <a href="qmap.html">QMap</a><QString,QVariant>
|
---|
| 268 | <li><tt>QVariant::Palette</tt> - a <a href="qpalette.html">QPalette</a>
|
---|
| 269 | <li><tt>QVariant::Pen</tt> - a <a href="qpen.html">QPen</a>
|
---|
| 270 | <li><tt>QVariant::Pixmap</tt> - a <a href="qpixmap.html">QPixmap</a>
|
---|
| 271 | <li><tt>QVariant::Point</tt> - a <a href="qpoint.html">QPoint</a>
|
---|
| 272 | <li><tt>QVariant::PointArray</tt> - a <a href="qpointarray.html">QPointArray</a>
|
---|
| 273 | <li><tt>QVariant::Rect</tt> - a <a href="qrect.html">QRect</a>
|
---|
| 274 | <li><tt>QVariant::Region</tt> - a <a href="qregion.html">QRegion</a>
|
---|
| 275 | <li><tt>QVariant::Size</tt> - a <a href="qsize.html">QSize</a>
|
---|
| 276 | <li><tt>QVariant::SizePolicy</tt> - a <a href="qsizepolicy.html">QSizePolicy</a>
|
---|
| 277 | <li><tt>QVariant::String</tt> - a <a href="qstring.html">QString</a>
|
---|
| 278 | <li><tt>QVariant::CString</tt> - a <a href="qcstring.html">QCString</a>
|
---|
| 279 | <li><tt>QVariant::StringList</tt> - a <a href="qstringlist.html">QStringList</a>
|
---|
| 280 | <li><tt>QVariant::Time</tt> - a <a href="qtime.html">QTime</a>
|
---|
| 281 | <li><tt>QVariant::UInt</tt> - an unsigned int
|
---|
| 282 | </ul><p> Note that Qt's definition of bool depends on the compiler.
|
---|
| 283 | <a href="qglobal-h.html">qglobal.h</a> has the system-dependent definition of bool.
|
---|
| 284 |
|
---|
| 285 | <hr><h2>Member Function Documentation</h2>
|
---|
| 286 | <h3 class=fn><a name="QVariant"></a>QVariant::QVariant ()
|
---|
| 287 | </h3>
|
---|
| 288 | Constructs an invalid variant.
|
---|
| 289 |
|
---|
| 290 | <h3 class=fn><a name="QVariant-10"></a>QVariant::QVariant ( bool val, int )
|
---|
| 291 | </h3>
|
---|
| 292 | Constructs a new variant with a boolean value, <em>val</em>. The integer
|
---|
| 293 | argument is a dummy, necessary for compatibility with some
|
---|
| 294 | compilers.
|
---|
| 295 |
|
---|
| 296 | <h3 class=fn><a name="QVariant-11"></a>QVariant::QVariant ( double val )
|
---|
| 297 | </h3>
|
---|
| 298 | Constructs a new variant with a floating point value, <em>val</em>.
|
---|
| 299 |
|
---|
| 300 | <h3 class=fn><a name="QVariant-12"></a>QVariant::QVariant ( <a href="qsizepolicy.html">QSizePolicy</a> val )
|
---|
| 301 | </h3>
|
---|
| 302 | Constructs a new variant with a size policy value, <em>val</em>.
|
---|
| 303 |
|
---|
| 304 | <h3 class=fn><a name="QVariant-2"></a>QVariant::QVariant ( const <a href="qvariant.html">QVariant</a> & p )
|
---|
| 305 | </h3>
|
---|
| 306 | Constructs a copy of the variant, <em>p</em>, passed as the argument to
|
---|
| 307 | 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>
|
---|
| 308 | is made if the stored data type is <a href="shclass.html#explicitly-shared">explicitly shared</a>, as e.g.
|
---|
| 309 | <a href="qimage.html">QImage</a> is.
|
---|
| 310 |
|
---|
| 311 | <h3 class=fn><a name="QVariant-3"></a>QVariant::QVariant ( <a href="qdatastream.html">QDataStream</a> & s )
|
---|
| 312 | </h3>
|
---|
| 313 | Reads the variant from the data stream, <em>s</em>.
|
---|
| 314 |
|
---|
| 315 | <h3 class=fn><a name="QVariant-4"></a>QVariant::QVariant ( const <a href="qstring.html">QString</a> & val )
|
---|
| 316 | </h3>
|
---|
| 317 | Constructs a new variant with a string value, <em>val</em>.
|
---|
| 318 |
|
---|
| 319 | <h3 class=fn><a name="QVariant-5"></a>QVariant::QVariant ( const <a href="qcstring.html">QCString</a> & val )
|
---|
| 320 | </h3>
|
---|
| 321 | Constructs a new variant with a C-string value, <em>val</em>.
|
---|
| 322 | <p> If you want to modify the <a href="qcstring.html">QCString</a> after you've passed it to this
|
---|
| 323 | constructor, we recommend passing a <a href="shclass.html#deep-copy">deep copy</a> (see
|
---|
| 324 | <a href="qcstring.html#copy">QCString::copy</a>()).
|
---|
| 325 |
|
---|
| 326 | <h3 class=fn><a name="QVariant-6"></a>QVariant::QVariant ( const char * val )
|
---|
| 327 | </h3>
|
---|
| 328 | Constructs a new variant with a C-string value of <em>val</em> if <em>val</em>
|
---|
| 329 | is non-null. The variant creates a <a href="shclass.html#deep-copy">deep copy</a> of <em>val</em>.
|
---|
| 330 | <p> If <em>val</em> is null, the resulting variant has type Invalid.
|
---|
| 331 |
|
---|
| 332 | <h3 class=fn><a name="QVariant-7"></a>QVariant::QVariant ( const <a href="qstringlist.html">QStringList</a> & val )
|
---|
| 333 | </h3>
|
---|
| 334 | Constructs a new variant with a string list value, <em>val</em>.
|
---|
| 335 |
|
---|
| 336 | <h3 class=fn><a name="QVariant-8"></a>QVariant::QVariant ( const <a href="qfont.html">QFont</a> & val )
|
---|
| 337 | </h3>
|
---|
| 338 | Constructs a new variant with a font value, <em>val</em>.
|
---|
| 339 |
|
---|
| 340 | <h3 class=fn><a name="QVariant-9"></a>QVariant::QVariant ( const <a href="qpixmap.html">QPixmap</a> & val )
|
---|
| 341 | </h3>
|
---|
| 342 | Constructs a new variant with a pixmap value, <em>val</em>.
|
---|
| 343 |
|
---|
| 344 | <h3 class=fn><a name="QVariant-a"></a>QVariant::QVariant ( const <a href="qimage.html">QImage</a> & val )
|
---|
| 345 | </h3>
|
---|
| 346 | Constructs a new variant with an image value, <em>val</em>.
|
---|
| 347 | <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
|
---|
| 348 | changing the image you've passed later on.
|
---|
| 349 |
|
---|
| 350 | <h3 class=fn><a name="QVariant-b"></a>QVariant::QVariant ( const <a href="qbrush.html">QBrush</a> & val )
|
---|
| 351 | </h3>
|
---|
| 352 | Constructs a new variant with a brush value, <em>val</em>.
|
---|
| 353 |
|
---|
| 354 | <h3 class=fn><a name="QVariant-c"></a>QVariant::QVariant ( const <a href="qpoint.html">QPoint</a> & val )
|
---|
| 355 | </h3>
|
---|
| 356 | Constructs a new variant with a point value, <em>val</em>.
|
---|
| 357 |
|
---|
| 358 | <h3 class=fn><a name="QVariant-d"></a>QVariant::QVariant ( const <a href="qrect.html">QRect</a> & val )
|
---|
| 359 | </h3>
|
---|
| 360 | Constructs a new variant with a rect value, <em>val</em>.
|
---|
| 361 |
|
---|
| 362 | <h3 class=fn><a name="QVariant-e"></a>QVariant::QVariant ( const <a href="qsize.html">QSize</a> & val )
|
---|
| 363 | </h3>
|
---|
| 364 | Constructs a new variant with a size value, <em>val</em>.
|
---|
| 365 |
|
---|
| 366 | <h3 class=fn><a name="QVariant-f"></a>QVariant::QVariant ( const <a href="qcolor.html">QColor</a> & val )
|
---|
| 367 | </h3>
|
---|
| 368 | Constructs a new variant with a color value, <em>val</em>.
|
---|
| 369 |
|
---|
| 370 | <h3 class=fn><a name="QVariant-g"></a>QVariant::QVariant ( const <a href="qpalette.html">QPalette</a> & val )
|
---|
| 371 | </h3>
|
---|
| 372 | Constructs a new variant with a color palette value, <em>val</em>.
|
---|
| 373 |
|
---|
| 374 | <h3 class=fn><a name="QVariant-h"></a>QVariant::QVariant ( const <a href="qcolorgroup.html">QColorGroup</a> & val )
|
---|
| 375 | </h3>
|
---|
| 376 | Constructs a new variant with a color group value, <em>val</em>.
|
---|
| 377 |
|
---|
| 378 | <h3 class=fn><a name="QVariant-i"></a>QVariant::QVariant ( const <a href="qiconset.html">QIconSet</a> & val )
|
---|
| 379 | </h3>
|
---|
| 380 | Constructs a new variant with an icon set value, <em>val</em>.
|
---|
| 381 |
|
---|
| 382 | <h3 class=fn><a name="QVariant-j"></a>QVariant::QVariant ( const <a href="qpointarray.html">QPointArray</a> & val )
|
---|
| 383 | </h3>
|
---|
| 384 | Constructs a new variant with a point array value, <em>val</em>.
|
---|
| 385 | <p> Because <a href="qpointarray.html">QPointArray</a> is <a href="shclass.html#explicitly-shared">explicitly shared</a>, you may need to pass a
|
---|
| 386 | <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
|
---|
| 387 | intend changing the point array you've passed later on.
|
---|
| 388 |
|
---|
| 389 | <h3 class=fn><a name="QVariant-k"></a>QVariant::QVariant ( const <a href="qregion.html">QRegion</a> & val )
|
---|
| 390 | </h3>
|
---|
| 391 | Constructs a new variant with a region value, <em>val</em>.
|
---|
| 392 |
|
---|
| 393 | <h3 class=fn><a name="QVariant-l"></a>QVariant::QVariant ( const <a href="qbitmap.html">QBitmap</a> & val )
|
---|
| 394 | </h3>
|
---|
| 395 | Constructs a new variant with a bitmap value, <em>val</em>.
|
---|
| 396 |
|
---|
| 397 | <h3 class=fn><a name="QVariant-m"></a>QVariant::QVariant ( const <a href="qcursor.html">QCursor</a> & val )
|
---|
| 398 | </h3>
|
---|
| 399 | Constructs a new variant with a cursor value, <em>val</em>.
|
---|
| 400 |
|
---|
| 401 | <h3 class=fn><a name="QVariant-n"></a>QVariant::QVariant ( const <a href="qdate.html">QDate</a> & val )
|
---|
| 402 | </h3>
|
---|
| 403 | Constructs a new variant with a date value, <em>val</em>.
|
---|
| 404 |
|
---|
| 405 | <h3 class=fn><a name="QVariant-o"></a>QVariant::QVariant ( const <a href="qtime.html">QTime</a> & val )
|
---|
| 406 | </h3>
|
---|
| 407 | Constructs a new variant with a time value, <em>val</em>.
|
---|
| 408 |
|
---|
| 409 | <h3 class=fn><a name="QVariant-p"></a>QVariant::QVariant ( const <a href="qdatetime.html">QDateTime</a> & val )
|
---|
| 410 | </h3>
|
---|
| 411 | Constructs a new variant with a date/time value, <em>val</em>.
|
---|
| 412 |
|
---|
| 413 | <h3 class=fn><a name="QVariant-q"></a>QVariant::QVariant ( const <a href="qbytearray.html">QByteArray</a> & val )
|
---|
| 414 | </h3>
|
---|
| 415 | Constructs a new variant with a bytearray value, <em>val</em>.
|
---|
| 416 |
|
---|
| 417 | <h3 class=fn><a name="QVariant-r"></a>QVariant::QVariant ( const <a href="qbitarray.html">QBitArray</a> & val )
|
---|
| 418 | </h3>
|
---|
| 419 | Constructs a new variant with a bitarray value, <em>val</em>.
|
---|
| 420 |
|
---|
| 421 | <h3 class=fn><a name="QVariant-s"></a>QVariant::QVariant ( const <a href="qkeysequence.html">QKeySequence</a> & val )
|
---|
| 422 | </h3>
|
---|
| 423 | Constructs a new variant with a key sequence value, <em>val</em>.
|
---|
| 424 |
|
---|
| 425 | <h3 class=fn><a name="QVariant-t"></a>QVariant::QVariant ( const <a href="qpen.html">QPen</a> & val )
|
---|
| 426 | </h3>
|
---|
| 427 | Constructs a new variant with a pen value, <em>val</em>.
|
---|
| 428 |
|
---|
| 429 | <h3 class=fn><a name="QVariant-u"></a>QVariant::QVariant ( const <a href="qvaluelist.html">QValueList</a><QVariant> & val )
|
---|
| 430 | </h3>
|
---|
| 431 | Constructs a new variant with a list value, <em>val</em>.
|
---|
| 432 |
|
---|
| 433 | <h3 class=fn><a name="QVariant-v"></a>QVariant::QVariant ( const <a href="qmap.html">QMap</a><QString, QVariant> & val )
|
---|
| 434 | </h3>
|
---|
| 435 | Constructs a new variant with a map of QVariants, <em>val</em>.
|
---|
| 436 |
|
---|
| 437 | <h3 class=fn><a name="QVariant-w"></a>QVariant::QVariant ( int val )
|
---|
| 438 | </h3>
|
---|
| 439 | Constructs a new variant with an integer value, <em>val</em>.
|
---|
| 440 |
|
---|
| 441 | <h3 class=fn><a name="QVariant-x"></a>QVariant::QVariant ( uint val )
|
---|
| 442 | </h3>
|
---|
| 443 | Constructs a new variant with an unsigned integer value, <em>val</em>.
|
---|
| 444 |
|
---|
| 445 | <h3 class=fn><a name="QVariant-y"></a>QVariant::QVariant ( Q_LLONG val )
|
---|
| 446 | </h3>
|
---|
| 447 | Constructs a new variant with a long long integer value, <em>val</em>.
|
---|
| 448 |
|
---|
| 449 | <h3 class=fn><a name="QVariant-z"></a>QVariant::QVariant ( Q_ULLONG val )
|
---|
| 450 | </h3>
|
---|
| 451 | Constructs a new variant with an unsigned long long integer value, <em>val</em>.
|
---|
| 452 |
|
---|
| 453 | <h3 class=fn><a name="~QVariant"></a>QVariant::~QVariant ()
|
---|
| 454 | </h3>
|
---|
| 455 | Destroys the QVariant and the contained object.
|
---|
| 456 | <p> Note that subclasses that reimplement <a href="#clear">clear</a>() should reimplement
|
---|
| 457 | the destructor to call clear(). This destructor calls clear(), but
|
---|
| 458 | because it is the destructor, <a href="#clear">QVariant::clear</a>() is called rather
|
---|
| 459 | than a subclass's clear().
|
---|
| 460 |
|
---|
| 461 | <h3 class=fn><a href="qbitarray.html">QBitArray</a> & <a name="asBitArray"></a>QVariant::asBitArray ()
|
---|
| 462 | </h3>
|
---|
| 463 |
|
---|
| 464 | <p> Tries to convert the variant to hold a <a href="qbitarray.html">QBitArray</a> value. If that is
|
---|
| 465 | not possible then the variant is set to an empty bitarray.
|
---|
| 466 | <p> Returns a reference to the stored bitarray.
|
---|
| 467 | <p> <p>See also <a href="#toBitArray">toBitArray</a>().
|
---|
| 468 |
|
---|
| 469 | <h3 class=fn><a href="qbitmap.html">QBitmap</a> & <a name="asBitmap"></a>QVariant::asBitmap ()
|
---|
| 470 | </h3>
|
---|
| 471 |
|
---|
| 472 | <p> Tries to convert the variant to hold a bitmap value. If that is
|
---|
| 473 | not possible the variant is set to a null bitmap.
|
---|
| 474 | <p> Returns a reference to the stored bitmap.
|
---|
| 475 | <p> <p>See also <a href="#toBitmap">toBitmap</a>().
|
---|
| 476 |
|
---|
| 477 | <h3 class=fn>bool & <a name="asBool"></a>QVariant::asBool ()
|
---|
| 478 | </h3>
|
---|
| 479 | Returns the variant's value as bool reference.
|
---|
| 480 |
|
---|
| 481 | <h3 class=fn><a href="qbrush.html">QBrush</a> & <a name="asBrush"></a>QVariant::asBrush ()
|
---|
| 482 | </h3>
|
---|
| 483 |
|
---|
| 484 | <p> Tries to convert the variant to hold a brush value. If that is not
|
---|
| 485 | possible the variant is set to a default black brush.
|
---|
| 486 | <p> Returns a reference to the stored brush.
|
---|
| 487 | <p> <p>See also <a href="#toBrush">toBrush</a>().
|
---|
| 488 |
|
---|
| 489 | <h3 class=fn><a href="qbytearray.html">QByteArray</a> & <a name="asByteArray"></a>QVariant::asByteArray ()
|
---|
| 490 | </h3>
|
---|
| 491 |
|
---|
| 492 | <p> Tries to convert the variant to hold a <a href="qbytearray.html">QByteArray</a> value. If that
|
---|
| 493 | is not possible then the variant is set to an empty bytearray.
|
---|
| 494 | <p> Returns a reference to the stored bytearray.
|
---|
| 495 | <p> <p>See also <a href="#toByteArray">toByteArray</a>().
|
---|
| 496 |
|
---|
| 497 | <h3 class=fn><a href="qcstring.html">QCString</a> & <a name="asCString"></a>QVariant::asCString ()
|
---|
| 498 | </h3>
|
---|
| 499 |
|
---|
| 500 | <p> Tries to convert the variant to hold a string value. If that is
|
---|
| 501 | not possible the variant is set to an empty string.
|
---|
| 502 | <p> Returns a reference to the stored string.
|
---|
| 503 | <p> <p>See also <a href="#toCString">toCString</a>().
|
---|
| 504 |
|
---|
| 505 | <h3 class=fn><a href="qcolor.html">QColor</a> & <a name="asColor"></a>QVariant::asColor ()
|
---|
| 506 | </h3>
|
---|
| 507 |
|
---|
| 508 | <p> Tries to convert the variant to hold a <a href="qcolor.html">QColor</a> value. If that is
|
---|
| 509 | not possible the variant is set to an invalid color.
|
---|
| 510 | <p> Returns a reference to the stored color.
|
---|
| 511 | <p> <p>See also <a href="#toColor">toColor</a>() and <a href="qcolor.html#isValid">QColor::isValid</a>().
|
---|
| 512 |
|
---|
| 513 | <h3 class=fn><a href="qcolorgroup.html">QColorGroup</a> & <a name="asColorGroup"></a>QVariant::asColorGroup ()
|
---|
| 514 | </h3>
|
---|
| 515 |
|
---|
| 516 | <p> Tries to convert the variant to hold a <a href="qcolorgroup.html">QColorGroup</a> value. If that
|
---|
| 517 | is not possible the variant is set to a color group of all black
|
---|
| 518 | colors.
|
---|
| 519 | <p> Returns a reference to the stored color group.
|
---|
| 520 | <p> <p>See also <a href="#toColorGroup">toColorGroup</a>().
|
---|
| 521 |
|
---|
| 522 | <h3 class=fn><a href="qcursor.html">QCursor</a> & <a name="asCursor"></a>QVariant::asCursor ()
|
---|
| 523 | </h3>
|
---|
| 524 |
|
---|
| 525 | <p> Tries to convert the variant to hold a <a href="qcursor.html">QCursor</a> value. If that is
|
---|
| 526 | not possible the variant is set to a default arrow cursor.
|
---|
| 527 | <p> Returns a reference to the stored cursor.
|
---|
| 528 | <p> <p>See also <a href="#toCursor">toCursor</a>().
|
---|
| 529 |
|
---|
| 530 | <h3 class=fn><a href="qdate.html">QDate</a> & <a name="asDate"></a>QVariant::asDate ()
|
---|
| 531 | </h3>
|
---|
| 532 |
|
---|
| 533 | <p> Tries to convert the variant to hold a <a href="qdate.html">QDate</a> value. If that is not
|
---|
| 534 | possible then the variant is set to an invalid date.
|
---|
| 535 | <p> Returns a reference to the stored date.
|
---|
| 536 | <p> <p>See also <a href="#toDate">toDate</a>().
|
---|
| 537 |
|
---|
| 538 | <h3 class=fn><a href="qdatetime.html">QDateTime</a> & <a name="asDateTime"></a>QVariant::asDateTime ()
|
---|
| 539 | </h3>
|
---|
| 540 |
|
---|
| 541 | <p> Tries to convert the variant to hold a <a href="qdatetime.html">QDateTime</a> value. If that is
|
---|
| 542 | not possible then the variant is set to an invalid date/time.
|
---|
| 543 | <p> Returns a reference to the stored date/time.
|
---|
| 544 | <p> <p>See also <a href="#toDateTime">toDateTime</a>().
|
---|
| 545 |
|
---|
| 546 | <h3 class=fn>double & <a name="asDouble"></a>QVariant::asDouble ()
|
---|
| 547 | </h3>
|
---|
| 548 | Returns the variant's value as double reference.
|
---|
| 549 |
|
---|
| 550 | <h3 class=fn><a href="qfont.html">QFont</a> & <a name="asFont"></a>QVariant::asFont ()
|
---|
| 551 | </h3>
|
---|
| 552 |
|
---|
| 553 | <p> Tries to convert the variant to hold a <a href="qfont.html">QFont</a>. If that is not
|
---|
| 554 | possible the variant is set to the application's default font.
|
---|
| 555 | <p> Returns a reference to the stored font.
|
---|
| 556 | <p> <p>See also <a href="#toFont">toFont</a>().
|
---|
| 557 |
|
---|
| 558 | <h3 class=fn><a href="qiconset.html">QIconSet</a> & <a name="asIconSet"></a>QVariant::asIconSet ()
|
---|
| 559 | </h3>
|
---|
| 560 |
|
---|
| 561 | <p> Tries to convert the variant to hold a <a href="qiconset.html">QIconSet</a> value. If that is
|
---|
| 562 | not possible the variant is set to an empty iconset.
|
---|
| 563 | <p> Returns a reference to the stored iconset.
|
---|
| 564 | <p> <p>See also <a href="#toIconSet">toIconSet</a>().
|
---|
| 565 |
|
---|
| 566 | <h3 class=fn><a href="qimage.html">QImage</a> & <a name="asImage"></a>QVariant::asImage ()
|
---|
| 567 | </h3>
|
---|
| 568 |
|
---|
| 569 | <p> Tries to convert the variant to hold an image value. If that is
|
---|
| 570 | not possible the variant is set to a null image.
|
---|
| 571 | <p> Returns a reference to the stored image.
|
---|
| 572 | <p> <p>See also <a href="#toImage">toImage</a>().
|
---|
| 573 |
|
---|
| 574 | <h3 class=fn>int & <a name="asInt"></a>QVariant::asInt ()
|
---|
| 575 | </h3>
|
---|
| 576 | Returns the variant's value as int reference.
|
---|
| 577 |
|
---|
| 578 | <h3 class=fn><a href="qkeysequence.html">QKeySequence</a> & <a name="asKeySequence"></a>QVariant::asKeySequence ()
|
---|
| 579 | </h3>
|
---|
| 580 |
|
---|
| 581 | <p> Tries to convert the variant to hold a <a href="qkeysequence.html">QKeySequence</a> value. If that
|
---|
| 582 | is not possible then the variant is set to an empty key sequence.
|
---|
| 583 | <p> Returns a reference to the stored key sequence.
|
---|
| 584 | <p> <p>See also <a href="#toKeySequence">toKeySequence</a>().
|
---|
| 585 |
|
---|
| 586 | <h3 class=fn><a href="qvaluelist.html">QValueList</a><QVariant> & <a name="asList"></a>QVariant::asList ()
|
---|
| 587 | </h3>
|
---|
| 588 | Returns the variant's value as variant list reference.
|
---|
| 589 | <p> Note that if you want to iterate over the list, you should iterate
|
---|
| 590 | over a copy, e.g.
|
---|
| 591 | <pre>
|
---|
| 592 | <a href="qvaluelist.html">QValueList</a><QVariant> list = myVariant.asList();
|
---|
| 593 | QValueList<QVariant>::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
|
---|
| 594 | while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
|
---|
| 595 | myProcessing( *it );
|
---|
| 596 | ++it;
|
---|
| 597 | }
|
---|
| 598 | </pre>
|
---|
| 599 |
|
---|
| 600 |
|
---|
| 601 | <h3 class=fn>Q_LLONG & <a name="asLongLong"></a>QVariant::asLongLong ()
|
---|
| 602 | </h3>
|
---|
| 603 | Returns the variant's value as long long reference.
|
---|
| 604 |
|
---|
| 605 | <h3 class=fn><a href="qmap.html">QMap</a><QString, QVariant> & <a name="asMap"></a>QVariant::asMap ()
|
---|
| 606 | </h3>
|
---|
| 607 | Returns the variant's value as variant map reference.
|
---|
| 608 | <p> Note that if you want to iterate over the map, you should iterate
|
---|
| 609 | over a copy, e.g.
|
---|
| 610 | <pre>
|
---|
| 611 | <a href="qmap.html">QMap</a><QString, QVariant> map = myVariant.asMap();
|
---|
| 612 | QMap<QString, QVariant>::Iterator it = map.<a href="qmap.html#begin">begin</a>();
|
---|
| 613 | while( it != map.<a href="qmap.html#end">end</a>() ) {
|
---|
| 614 | myProcessing( *it );
|
---|
| 615 | ++it;
|
---|
| 616 | }
|
---|
| 617 | </pre>
|
---|
| 618 |
|
---|
| 619 |
|
---|
| 620 | <h3 class=fn><a href="qpalette.html">QPalette</a> & <a name="asPalette"></a>QVariant::asPalette ()
|
---|
| 621 | </h3>
|
---|
| 622 |
|
---|
| 623 | <p> Tries to convert the variant to hold a <a href="qpalette.html">QPalette</a> value. If that is
|
---|
| 624 | not possible the variant is set to a palette of black colors.
|
---|
| 625 | <p> Returns a reference to the stored palette.
|
---|
| 626 | <p> <p>See also <a href="#toString">toString</a>().
|
---|
| 627 |
|
---|
| 628 | <h3 class=fn><a href="qpen.html">QPen</a> & <a name="asPen"></a>QVariant::asPen ()
|
---|
| 629 | </h3>
|
---|
| 630 | <p> Tries to convert the variant to hold a <a href="qpen.html">QPen</a> value. If that
|
---|
| 631 | is not possible then the variant is set to an empty pen.
|
---|
| 632 | <p> Returns a reference to the stored pen.
|
---|
| 633 | <p> <p>See also <a href="#toPen">toPen</a>().
|
---|
| 634 |
|
---|
| 635 | <h3 class=fn><a href="qpixmap.html">QPixmap</a> & <a name="asPixmap"></a>QVariant::asPixmap ()
|
---|
| 636 | </h3>
|
---|
| 637 |
|
---|
| 638 | <p> Tries to convert the variant to hold a pixmap value. If that is
|
---|
| 639 | not possible the variant is set to a null pixmap.
|
---|
| 640 | <p> Returns a reference to the stored pixmap.
|
---|
| 641 | <p> <p>See also <a href="#toPixmap">toPixmap</a>().
|
---|
| 642 |
|
---|
| 643 | <h3 class=fn><a href="qpoint.html">QPoint</a> & <a name="asPoint"></a>QVariant::asPoint ()
|
---|
| 644 | </h3>
|
---|
| 645 |
|
---|
| 646 | <p> Tries to convert the variant to hold a point value. If that is not
|
---|
| 647 | possible the variant is set to a (0, 0) point.
|
---|
| 648 | <p> Returns a reference to the stored point.
|
---|
| 649 | <p> <p>See also <a href="#toPoint">toPoint</a>().
|
---|
| 650 |
|
---|
| 651 | <h3 class=fn><a href="qpointarray.html">QPointArray</a> & <a name="asPointArray"></a>QVariant::asPointArray ()
|
---|
| 652 | </h3>
|
---|
| 653 |
|
---|
| 654 | <p> Tries to convert the variant to hold a <a href="qpointarray.html">QPointArray</a> value. If that
|
---|
| 655 | is not possible the variant is set to an empty point array.
|
---|
| 656 | <p> Returns a reference to the stored point array.
|
---|
| 657 | <p> <p>See also <a href="#toPointArray">toPointArray</a>().
|
---|
| 658 |
|
---|
| 659 | <h3 class=fn><a href="qrect.html">QRect</a> & <a name="asRect"></a>QVariant::asRect ()
|
---|
| 660 | </h3>
|
---|
| 661 |
|
---|
| 662 | <p> Tries to convert the variant to hold a rectangle value. If that is
|
---|
| 663 | not possible the variant is set to an empty rectangle.
|
---|
| 664 | <p> Returns a reference to the stored rectangle.
|
---|
| 665 | <p> <p>See also <a href="#toRect">toRect</a>().
|
---|
| 666 |
|
---|
| 667 | <h3 class=fn><a href="qregion.html">QRegion</a> & <a name="asRegion"></a>QVariant::asRegion ()
|
---|
| 668 | </h3>
|
---|
| 669 |
|
---|
| 670 | <p> Tries to convert the variant to hold a <a href="qregion.html">QRegion</a> value. If that is
|
---|
| 671 | not possible the variant is set to a null region.
|
---|
| 672 | <p> Returns a reference to the stored region.
|
---|
| 673 | <p> <p>See also <a href="#toRegion">toRegion</a>().
|
---|
| 674 |
|
---|
| 675 | <h3 class=fn><a href="qsize.html">QSize</a> & <a name="asSize"></a>QVariant::asSize ()
|
---|
| 676 | </h3>
|
---|
| 677 |
|
---|
| 678 | <p> Tries to convert the variant to hold a <a href="qsize.html">QSize</a> value. If that is not
|
---|
| 679 | possible the variant is set to an invalid size.
|
---|
| 680 | <p> Returns a reference to the stored size.
|
---|
| 681 | <p> <p>See also <a href="#toSize">toSize</a>() and <a href="qsize.html#isValid">QSize::isValid</a>().
|
---|
| 682 |
|
---|
| 683 | <h3 class=fn><a href="qsizepolicy.html">QSizePolicy</a> & <a name="asSizePolicy"></a>QVariant::asSizePolicy ()
|
---|
| 684 | </h3>
|
---|
| 685 |
|
---|
| 686 | <p> Tries to convert the variant to hold a <a href="qsizepolicy.html">QSizePolicy</a> value. If that
|
---|
| 687 | fails, the variant is set to an arbitrary (valid) size policy.
|
---|
| 688 |
|
---|
| 689 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="asString"></a>QVariant::asString ()
|
---|
| 690 | </h3>
|
---|
| 691 |
|
---|
| 692 | <p> Tries to convert the variant to hold a string value. If that is
|
---|
| 693 | not possible the variant is set to an empty string.
|
---|
| 694 | <p> Returns a reference to the stored string.
|
---|
| 695 | <p> <p>See also <a href="#toString">toString</a>().
|
---|
| 696 |
|
---|
| 697 | <h3 class=fn><a href="qstringlist.html">QStringList</a> & <a name="asStringList"></a>QVariant::asStringList ()
|
---|
| 698 | </h3>
|
---|
| 699 |
|
---|
| 700 | <p> Tries to convert the variant to hold a <a href="qstringlist.html">QStringList</a> value. If that
|
---|
| 701 | is not possible the variant is set to an empty string list.
|
---|
| 702 | <p> Returns a reference to the stored string list.
|
---|
| 703 | <p> Note that if you want to iterate over the list, you should
|
---|
| 704 | iterate over a copy, e.g.
|
---|
| 705 | <pre>
|
---|
| 706 | <a href="qstringlist.html">QStringList</a> list = myVariant.asStringList();
|
---|
| 707 | QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
|
---|
| 708 | while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
|
---|
| 709 | myProcessing( *it );
|
---|
| 710 | ++it;
|
---|
| 711 | }
|
---|
| 712 | </pre>
|
---|
| 713 |
|
---|
| 714 | <p> <p>See also <a href="#toStringList">toStringList</a>().
|
---|
| 715 |
|
---|
| 716 | <h3 class=fn><a href="qtime.html">QTime</a> & <a name="asTime"></a>QVariant::asTime ()
|
---|
| 717 | </h3>
|
---|
| 718 |
|
---|
| 719 | <p> Tries to convert the variant to hold a <a href="qtime.html">QTime</a> value. If that is not
|
---|
| 720 | possible then the variant is set to an invalid time.
|
---|
| 721 | <p> Returns a reference to the stored time.
|
---|
| 722 | <p> <p>See also <a href="#toTime">toTime</a>().
|
---|
| 723 |
|
---|
| 724 | <h3 class=fn>uint & <a name="asUInt"></a>QVariant::asUInt ()
|
---|
| 725 | </h3>
|
---|
| 726 | Returns the variant's value as unsigned int reference.
|
---|
| 727 |
|
---|
| 728 | <h3 class=fn>Q_ULLONG & <a name="asULongLong"></a>QVariant::asULongLong ()
|
---|
| 729 | </h3>
|
---|
| 730 | Returns the variant's value as unsigned long long reference.
|
---|
| 731 |
|
---|
| 732 | <h3 class=fn>bool <a name="canCast"></a>QVariant::canCast ( <a href="qvariant.html#Type-enum">Type</a> t ) const
|
---|
| 733 | </h3>
|
---|
| 734 | Returns TRUE if the variant's type can be cast to the requested
|
---|
| 735 | type, <em>t</em>. Such casting is done automatically when calling the
|
---|
| 736 | <a href="#toInt">toInt</a>(), <a href="#toBool">toBool</a>(), ... or <a href="#asInt">asInt</a>(), <a href="#asBool">asBool</a>(), ... methods.
|
---|
| 737 | <p> The following casts are done automatically:
|
---|
| 738 | <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
| 739 | <tr bgcolor="#a2c511"> <th valign="top">Type <th valign="top">Automatically Cast To
|
---|
| 740 | <tr bgcolor="#f0f0f0"> <td valign="top">Bool <td valign="top">Double, Int, UInt, LongLong, ULongLong, String, CString, ByteArray
|
---|
| 741 | <tr bgcolor="#d0d0d0"> <td valign="top">Color <td valign="top">String. CString. ByteArray
|
---|
| 742 | <tr bgcolor="#f0f0f0"> <td valign="top">Date <td valign="top">String, CString, ByteArray, DateTime
|
---|
| 743 | <tr bgcolor="#d0d0d0"> <td valign="top">DateTime <td valign="top">String, CString, ByteArray, Date, Time
|
---|
| 744 | <tr bgcolor="#f0f0f0"> <td valign="top">Double <td valign="top">String, CString, ByteArray, Int, Bool, UInt, LongLong, ULongLong
|
---|
| 745 | <tr bgcolor="#d0d0d0"> <td valign="top">Font <td valign="top">String, CString, ByteArray
|
---|
| 746 | <tr bgcolor="#f0f0f0"> <td valign="top">Int <td valign="top">String, CString, ByteArray, Double, Bool, UInt, LongLong, ULongLong, KeySequence
|
---|
| 747 | <tr bgcolor="#d0d0d0"> <td valign="top">LongLong <td valign="top">String, CString, ByteArray, Double, Bool, UInt, LongLong, ULongLong, KeySequence
|
---|
| 748 | <tr bgcolor="#f0f0f0"> <td valign="top">ULongLong <td valign="top">String, CString, ByteArray, Double, Bool, UInt, LongLong, ULongLong, KeySequence
|
---|
| 749 | <tr bgcolor="#d0d0d0"> <td valign="top">List <td valign="top">StringList (if the list contains only strings or
|
---|
| 750 | something that can be cast to a string)
|
---|
| 751 | <tr bgcolor="#f0f0f0"> <td valign="top">String <td valign="top">CString, ByteArray, CString, Int, UInt, Bool, Double, Date,
|
---|
| 752 | Time, DateTime, KeySequence, Font, Color
|
---|
| 753 | <tr bgcolor="#d0d0d0"> <td valign="top">CString <td valign="top">String, ByteArray, Int, UInt, Bool, Double, Date, ULongLong, LongLong
|
---|
| 754 | <tr bgcolor="#f0f0f0"> <td valign="top">ByteArray <td valign="top">String, CString, Int, UInt, Bool, Double, Date, ULongLong, LongLong
|
---|
| 755 | <tr bgcolor="#d0d0d0"> <td valign="top">StringList <td valign="top">List
|
---|
| 756 | <tr bgcolor="#f0f0f0"> <td valign="top">Time <td valign="top">String
|
---|
| 757 | <tr bgcolor="#d0d0d0"> <td valign="top">Int <td valign="top">String, CString, ByteArray, Double, Bool, UInt, LongLong, ULongLong, KeySequence
|
---|
| 758 | <tr bgcolor="#f0f0f0"> <td valign="top">KeySequence <td valign="top">String, CString, ByteArray, Int, UInt, LongLong, ULongLong
|
---|
| 759 | </table></center>
|
---|
| 760 |
|
---|
| 761 | <h3 class=fn>bool <a name="cast"></a>QVariant::cast ( <a href="qvariant.html#Type-enum">Type</a> t )
|
---|
| 762 | </h3>
|
---|
| 763 | Casts the variant to the requested type. If the cast cannot be
|
---|
| 764 | done, the variant is set to the default value of the requested
|
---|
| 765 | type (e.g. an empty string if the requested type <em>t</em> is
|
---|
| 766 | QVariant::String, an empty point array if the requested type <em>t</em>
|
---|
| 767 | is QVariant::PointArray, etc). Returns TRUE if the current type of
|
---|
| 768 | the variant was successfully cast; otherwise returns FALSE.
|
---|
| 769 | <p> <p>See also <a href="#canCast">canCast</a>().
|
---|
| 770 |
|
---|
| 771 | <h3 class=fn>void <a name="clear"></a>QVariant::clear ()
|
---|
| 772 | </h3>
|
---|
| 773 | Convert this variant to type Invalid and free up any resources
|
---|
| 774 | used.
|
---|
| 775 |
|
---|
| 776 | <h3 class=fn>bool <a name="isNull"></a>QVariant::isNull () const
|
---|
| 777 | </h3>
|
---|
| 778 | Returns TRUE if this is a NULL variant, FALSE otherwise.
|
---|
| 779 |
|
---|
| 780 | <h3 class=fn>bool <a name="isValid"></a>QVariant::isValid () const
|
---|
| 781 | </h3>
|
---|
| 782 |
|
---|
| 783 | <p> Returns TRUE if the storage type of this variant is not
|
---|
| 784 | QVariant::Invalid; otherwise returns FALSE.
|
---|
| 785 |
|
---|
| 786 | <h3 class=fn><a href="qvaluelistconstiterator.html">QValueListConstIterator</a><QVariant> <a name="listBegin"></a>QVariant::listBegin () const
|
---|
| 787 | </h3>
|
---|
| 788 |
|
---|
| 789 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 790 | <p> Returns an iterator to the first item in the list if the variant's
|
---|
| 791 | type is appropriate; otherwise returns a null iterator.
|
---|
| 792 |
|
---|
| 793 | <h3 class=fn><a href="qvaluelistconstiterator.html">QValueListConstIterator</a><QVariant> <a name="listEnd"></a>QVariant::listEnd () const
|
---|
| 794 | </h3>
|
---|
| 795 |
|
---|
| 796 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 797 | <p> Returns the end iterator for the list if the variant's type is
|
---|
| 798 | appropriate; otherwise returns a null iterator.
|
---|
| 799 |
|
---|
| 800 | <h3 class=fn><a href="qmapconstiterator.html">QMapConstIterator</a><QString, QVariant> <a name="mapBegin"></a>QVariant::mapBegin () const
|
---|
| 801 | </h3>
|
---|
| 802 |
|
---|
| 803 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 804 | <p> Returns an iterator to the first item in the map, if the variant's
|
---|
| 805 | type is appropriate; otherwise returns a null iterator.
|
---|
| 806 |
|
---|
| 807 | <h3 class=fn><a href="qmapconstiterator.html">QMapConstIterator</a><QString, QVariant> <a name="mapEnd"></a>QVariant::mapEnd () const
|
---|
| 808 | </h3>
|
---|
| 809 |
|
---|
| 810 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 811 | <p> Returns the end iterator for the map, if the variant's type is
|
---|
| 812 | appropriate; otherwise returns a null iterator.
|
---|
| 813 |
|
---|
| 814 | <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
|
---|
| 815 | </h3>
|
---|
| 816 |
|
---|
| 817 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 818 | <p> Returns an iterator to the item in the map with <em>key</em> as key, if
|
---|
| 819 | the variant's type is appropriate and <em>key</em> is a valid key;
|
---|
| 820 | otherwise returns a null iterator.
|
---|
| 821 |
|
---|
| 822 | <h3 class=fn><a href="qvariant.html#Type-enum">Type</a> <a name="nameToType"></a>QVariant::nameToType ( const char * name )<tt> [static]</tt>
|
---|
| 823 | </h3>
|
---|
| 824 | Converts the string representation of the storage type given in <em>name</em>, to its enum representation.
|
---|
| 825 | <p> If the string representation cannot be converted to any enum
|
---|
| 826 | representation, the variant is set to <a href="#Type-enum">Invalid</a>.
|
---|
| 827 |
|
---|
| 828 | <h3 class=fn>bool <a name="operator!-eq"></a>QVariant::operator!= ( const <a href="qvariant.html">QVariant</a> & v ) const
|
---|
| 829 | </h3>
|
---|
| 830 | Compares this QVariant with <em>v</em> and returns TRUE if they are not
|
---|
| 831 | equal; otherwise returns FALSE.
|
---|
| 832 |
|
---|
| 833 | <h3 class=fn><a href="qvariant.html">QVariant</a> & <a name="operator-eq"></a>QVariant::operator= ( const <a href="qvariant.html">QVariant</a> & variant )
|
---|
| 834 | </h3>
|
---|
| 835 | Assigns the value of the variant <em>variant</em> to this variant.
|
---|
| 836 | <p> This is a <a href="shclass.html#deep-copy">deep copy</a> of the variant, but note that if the variant
|
---|
| 837 | 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
|
---|
| 838 | performed.
|
---|
| 839 |
|
---|
| 840 | <h3 class=fn>bool <a name="operator-eq-eq"></a>QVariant::operator== ( const <a href="qvariant.html">QVariant</a> & v ) const
|
---|
| 841 | </h3>
|
---|
| 842 | Compares this QVariant with <em>v</em> and returns TRUE if they are
|
---|
| 843 | equal; otherwise returns FALSE.
|
---|
| 844 |
|
---|
| 845 | <h3 class=fn><a href="qvaluelistconstiterator.html">QValueListConstIterator</a><QString> <a name="stringListBegin"></a>QVariant::stringListBegin () const
|
---|
| 846 | </h3>
|
---|
| 847 |
|
---|
| 848 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 849 | <p> Returns an iterator to the first string in the list if the
|
---|
| 850 | variant's type is StringList; otherwise returns a null iterator.
|
---|
| 851 |
|
---|
| 852 | <h3 class=fn><a href="qvaluelistconstiterator.html">QValueListConstIterator</a><QString> <a name="stringListEnd"></a>QVariant::stringListEnd () const
|
---|
| 853 | </h3>
|
---|
| 854 |
|
---|
| 855 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 856 | <p> Returns the end iterator for the list if the variant's type is
|
---|
| 857 | StringList; otherwise returns a null iterator.
|
---|
| 858 |
|
---|
| 859 | <h3 class=fn>const <a href="qbitarray.html">QBitArray</a> <a name="toBitArray"></a>QVariant::toBitArray () const
|
---|
| 860 | </h3>
|
---|
| 861 | Returns the variant as a <a href="qbitarray.html">QBitArray</a> if the variant has <a href="#type">type</a>()
|
---|
| 862 | BitArray; otherwise returns an empty bitarray.
|
---|
| 863 | <p> <p>See also <a href="#asBitArray">asBitArray</a>().
|
---|
| 864 |
|
---|
| 865 | <h3 class=fn>const <a href="qbitmap.html">QBitmap</a> <a name="toBitmap"></a>QVariant::toBitmap () const
|
---|
| 866 | </h3>
|
---|
| 867 | Returns the variant as a <a href="qbitmap.html">QBitmap</a> if the variant has <a href="#type">type</a>() Bitmap;
|
---|
| 868 | otherwise returns a null QBitmap.
|
---|
| 869 | <p> <p>See also <a href="#asBitmap">asBitmap</a>().
|
---|
| 870 |
|
---|
| 871 | <h3 class=fn>bool <a name="toBool"></a>QVariant::toBool () const
|
---|
| 872 | </h3>
|
---|
| 873 | Returns the variant as a bool if the variant can be cast to Bool;
|
---|
| 874 | otherWise returns FALSE.
|
---|
| 875 | <p> Returns TRUE if the variant has a numeric type and its value is
|
---|
| 876 | non-zero, or if the variant has type String, ByteArray or CString
|
---|
| 877 | and its lower-case content is not empty, "0" or "false"; otherwise
|
---|
| 878 | returns FALSE.
|
---|
| 879 | <p> <p>See also <a href="#asBool">asBool</a>() and <a href="#canCast">canCast</a>().
|
---|
| 880 |
|
---|
| 881 | <h3 class=fn>const <a href="qbrush.html">QBrush</a> <a name="toBrush"></a>QVariant::toBrush () const
|
---|
| 882 | </h3>
|
---|
| 883 | Returns the variant as a <a href="qbrush.html">QBrush</a> if the variant has <a href="#type">type</a>() Brush;
|
---|
| 884 | otherwise returns a default brush (with all black colors).
|
---|
| 885 | <p> <p>See also <a href="#asBrush">asBrush</a>().
|
---|
| 886 |
|
---|
| 887 | <h3 class=fn>const <a href="qbytearray.html">QByteArray</a> <a name="toByteArray"></a>QVariant::toByteArray () const
|
---|
| 888 | </h3>
|
---|
| 889 | Returns the variant as a <a href="qbytearray.html">QByteArray</a> if the variant can be cast to
|
---|
| 890 | a ByteArray; otherwise returns an empty bytearray.
|
---|
| 891 | <p> <p>See also <a href="#asByteArray">asByteArray</a>() and <a href="#canCast">canCast</a>().
|
---|
| 892 |
|
---|
| 893 | <h3 class=fn>const <a href="qcstring.html">QCString</a> <a name="toCString"></a>QVariant::toCString () const
|
---|
| 894 | </h3>
|
---|
| 895 | Returns the variant as a <a href="qcstring.html">QCString</a> if the variant can be cast to a
|
---|
| 896 | CString; otherwise returns 0.
|
---|
| 897 | <p> <p>See also <a href="#asCString">asCString</a>() and <a href="#canCast">canCast</a>().
|
---|
| 898 |
|
---|
| 899 | <h3 class=fn>const <a href="qcolor.html">QColor</a> <a name="toColor"></a>QVariant::toColor () const
|
---|
| 900 | </h3>
|
---|
| 901 | Returns the variant as a <a href="qcolor.html">QColor</a> if the variant can be cast to Color;
|
---|
| 902 | otherwise returns an invalid color.
|
---|
| 903 | <p> <p>See also <a href="#asColor">asColor</a>() and <a href="#canCast">canCast</a>().
|
---|
| 904 |
|
---|
| 905 | <h3 class=fn>const <a href="qcolorgroup.html">QColorGroup</a> <a name="toColorGroup"></a>QVariant::toColorGroup () const
|
---|
| 906 | </h3>
|
---|
| 907 | Returns the variant as a <a href="qcolorgroup.html">QColorGroup</a> if the variant has <a href="#type">type</a>()
|
---|
| 908 | ColorGroup; otherwise returns a completely black color group.
|
---|
| 909 | <p> <p>See also <a href="#asColorGroup">asColorGroup</a>().
|
---|
| 910 |
|
---|
| 911 | <h3 class=fn>const <a href="qcursor.html">QCursor</a> <a name="toCursor"></a>QVariant::toCursor () const
|
---|
| 912 | </h3>
|
---|
| 913 | Returns the variant as a <a href="qcursor.html">QCursor</a> if the variant has <a href="#type">type</a>() Cursor;
|
---|
| 914 | otherwise returns the default arrow cursor.
|
---|
| 915 | <p> <p>See also <a href="#asCursor">asCursor</a>().
|
---|
| 916 |
|
---|
| 917 | <h3 class=fn>const <a href="qdate.html">QDate</a> <a name="toDate"></a>QVariant::toDate () const
|
---|
| 918 | </h3>
|
---|
| 919 | Returns the variant as a <a href="qdate.html">QDate</a> if the variant can be cast to Date;
|
---|
| 920 | otherwise returns an invalid date.
|
---|
| 921 | <p> Note that if the <a href="#type">type</a>() is String, CString or ByteArray an invalid
|
---|
| 922 | date will be returned if the string cannot be parsed as a
|
---|
| 923 | Qt::ISODate format date.
|
---|
| 924 | <p> <p>See also <a href="#asDate">asDate</a>() and <a href="#canCast">canCast</a>().
|
---|
| 925 |
|
---|
| 926 | <h3 class=fn>const <a href="qdatetime.html">QDateTime</a> <a name="toDateTime"></a>QVariant::toDateTime () const
|
---|
| 927 | </h3>
|
---|
| 928 | Returns the variant as a <a href="qdatetime.html">QDateTime</a> if the variant can be cast to
|
---|
| 929 | DateTime; otherwise returns an invalid QDateTime.
|
---|
| 930 | <p> Note that if the <a href="#type">type</a>() is String, CString or ByteArray an invalid
|
---|
| 931 | QDateTime will be returned if the string cannot be parsed as a
|
---|
| 932 | Qt::ISODate format date/time.
|
---|
| 933 | <p> <p>See also <a href="#asDateTime">asDateTime</a>().
|
---|
| 934 |
|
---|
| 935 | <h3 class=fn>double <a name="toDouble"></a>QVariant::toDouble ( bool * ok = 0 ) const
|
---|
| 936 | </h3>
|
---|
| 937 | Returns the variant as a double if the variant can be cast to
|
---|
| 938 | Double; otherwise returns 0.0.
|
---|
| 939 | <p> If <em>ok</em> is non-null: <em>*ok</em> is set to TRUE if the value could be
|
---|
| 940 | converted to a double; otherwise <em>*ok</em> is set to FALSE.
|
---|
| 941 | <p> <p>See also <a href="#asDouble">asDouble</a>() and <a href="#canCast">canCast</a>().
|
---|
| 942 |
|
---|
| 943 | <h3 class=fn>const <a href="qfont.html">QFont</a> <a name="toFont"></a>QVariant::toFont () const
|
---|
| 944 | </h3>
|
---|
| 945 | Returns the variant as a <a href="qfont.html">QFont</a> if the variant can be cast to Font;
|
---|
| 946 | otherwise returns the application's default font.
|
---|
| 947 | <p> <p>See also <a href="#asFont">asFont</a>() and <a href="#canCast">canCast</a>().
|
---|
| 948 |
|
---|
| 949 | <h3 class=fn>const <a href="qiconset.html">QIconSet</a> <a name="toIconSet"></a>QVariant::toIconSet () const
|
---|
| 950 | </h3>
|
---|
| 951 | Returns the variant as a <a href="qiconset.html">QIconSet</a> if the variant has <a href="#type">type</a>()
|
---|
| 952 | IconSet; otherwise returns an icon set of null pixmaps.
|
---|
| 953 | <p> <p>See also <a href="#asIconSet">asIconSet</a>().
|
---|
| 954 |
|
---|
| 955 | <h3 class=fn>const <a href="qimage.html">QImage</a> <a name="toImage"></a>QVariant::toImage () const
|
---|
| 956 | </h3>
|
---|
| 957 | Returns the variant as a <a href="qimage.html">QImage</a> if the variant has <a href="#type">type</a>() Image;
|
---|
| 958 | otherwise returns a null image.
|
---|
| 959 | <p> <p>See also <a href="#asImage">asImage</a>().
|
---|
| 960 |
|
---|
| 961 | <h3 class=fn>int <a name="toInt"></a>QVariant::toInt ( bool * ok = 0 ) const
|
---|
| 962 | </h3>
|
---|
| 963 | Returns the variant as an int if the variant can be cast to Int;
|
---|
| 964 | otherwise returns 0.
|
---|
| 965 | <p> If <em>ok</em> is non-null: <em>*ok</em> is set to TRUE if the value could be
|
---|
| 966 | converted to an int; otherwise <em>*ok</em> is set to FALSE.
|
---|
| 967 | <p> <p>See also <a href="#asInt">asInt</a>() and <a href="#canCast">canCast</a>().
|
---|
| 968 |
|
---|
| 969 | <h3 class=fn>const <a href="qkeysequence.html">QKeySequence</a> <a name="toKeySequence"></a>QVariant::toKeySequence () const
|
---|
| 970 | </h3>
|
---|
| 971 | Returns the variant as a <a href="qkeysequence.html">QKeySequence</a> if the variant can be cast
|
---|
| 972 | to a KeySequence; otherwise returns an empty key sequence.
|
---|
| 973 | <p> <p>See also <a href="#asKeySequence">asKeySequence</a>() and <a href="#canCast">canCast</a>().
|
---|
| 974 |
|
---|
| 975 | <h3 class=fn>const <a href="qvaluelist.html">QValueList</a><QVariant> <a name="toList"></a>QVariant::toList () const
|
---|
| 976 | </h3>
|
---|
| 977 | Returns the variant as a <a href="qvaluelist.html">QValueList</a><QVariant> if the variant has
|
---|
| 978 | <a href="#type">type</a>() List or StringList; otherwise returns an empty list.
|
---|
| 979 | <p> Note that if you want to iterate over the list, you should iterate
|
---|
| 980 | over a copy, e.g.
|
---|
| 981 | <pre>
|
---|
| 982 | <a href="qvaluelist.html">QValueList</a><QVariant> list = myVariant.toList();
|
---|
| 983 | QValueList<QVariant>::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
|
---|
| 984 | while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
|
---|
| 985 | myProcessing( *it );
|
---|
| 986 | ++it;
|
---|
| 987 | }
|
---|
| 988 | </pre>
|
---|
| 989 |
|
---|
| 990 | <p> <p>See also <a href="#asList">asList</a>().
|
---|
| 991 |
|
---|
| 992 | <h3 class=fn>Q_LLONG <a name="toLongLong"></a>QVariant::toLongLong ( bool * ok = 0 ) const
|
---|
| 993 | </h3>
|
---|
| 994 | Returns the variant as a long long int if the variant can be cast
|
---|
| 995 | to LongLong; otherwise returns 0.
|
---|
| 996 | <p> If <em>ok</em> is non-null: <em>*ok</em> is set to TRUE if the value could be
|
---|
| 997 | converted to an int; otherwise <em>*ok</em> is set to FALSE.
|
---|
| 998 | <p> <p>See also <a href="#asLongLong">asLongLong</a>() and <a href="#canCast">canCast</a>().
|
---|
| 999 |
|
---|
| 1000 | <h3 class=fn>const <a href="qmap.html">QMap</a><QString, QVariant> <a name="toMap"></a>QVariant::toMap () const
|
---|
| 1001 | </h3>
|
---|
| 1002 | Returns the variant as a <a href="qmap.html">QMap</a><QString,QVariant> if the variant has
|
---|
| 1003 | <a href="#type">type</a>() Map; otherwise returns an empty map.
|
---|
| 1004 | <p> Note that if you want to iterate over the map, you should iterate
|
---|
| 1005 | over a copy, e.g.
|
---|
| 1006 | <pre>
|
---|
| 1007 | <a href="qmap.html">QMap</a><QString, QVariant> map = myVariant.toMap();
|
---|
| 1008 | QMap<QString, QVariant>::Iterator it = map.<a href="qmap.html#begin">begin</a>();
|
---|
| 1009 | while( it != map.<a href="qmap.html#end">end</a>() ) {
|
---|
| 1010 | myProcessing( *it );
|
---|
| 1011 | ++it;
|
---|
| 1012 | }
|
---|
| 1013 | </pre>
|
---|
| 1014 |
|
---|
| 1015 | <p> <p>See also <a href="#asMap">asMap</a>().
|
---|
| 1016 |
|
---|
| 1017 | <h3 class=fn>const <a href="qpalette.html">QPalette</a> <a name="toPalette"></a>QVariant::toPalette () const
|
---|
| 1018 | </h3>
|
---|
| 1019 | Returns the variant as a <a href="qpalette.html">QPalette</a> if the variant has <a href="#type">type</a>()
|
---|
| 1020 | Palette; otherwise returns a completely black palette.
|
---|
| 1021 | <p> <p>See also <a href="#asPalette">asPalette</a>().
|
---|
| 1022 |
|
---|
| 1023 | <h3 class=fn>const <a href="qpen.html">QPen</a> <a name="toPen"></a>QVariant::toPen () const
|
---|
| 1024 | </h3>
|
---|
| 1025 | Returns the variant as a <a href="qpen.html">QPen</a> if the variant has <a href="#type">type</a>()
|
---|
| 1026 | Pen; otherwise returns an empty QPen.
|
---|
| 1027 | <p> <p>See also <a href="#asPen">asPen</a>().
|
---|
| 1028 |
|
---|
| 1029 | <h3 class=fn>const <a href="qpixmap.html">QPixmap</a> <a name="toPixmap"></a>QVariant::toPixmap () const
|
---|
| 1030 | </h3>
|
---|
| 1031 | Returns the variant as a <a href="qpixmap.html">QPixmap</a> if the variant has <a href="#type">type</a>() Pixmap;
|
---|
| 1032 | otherwise returns a null pixmap.
|
---|
| 1033 | <p> <p>See also <a href="#asPixmap">asPixmap</a>().
|
---|
| 1034 |
|
---|
| 1035 | <h3 class=fn>const <a href="qpoint.html">QPoint</a> <a name="toPoint"></a>QVariant::toPoint () const
|
---|
| 1036 | </h3>
|
---|
| 1037 | Returns the variant as a <a href="qpoint.html">QPoint</a> if the variant has <a href="#type">type</a>() Point;
|
---|
| 1038 | otherwise returns a point (0, 0).
|
---|
| 1039 | <p> <p>See also <a href="#asPoint">asPoint</a>().
|
---|
| 1040 |
|
---|
| 1041 | <h3 class=fn>const <a href="qpointarray.html">QPointArray</a> <a name="toPointArray"></a>QVariant::toPointArray () const
|
---|
| 1042 | </h3>
|
---|
| 1043 | Returns the variant as a <a href="qpointarray.html">QPointArray</a> if the variant has <a href="#type">type</a>()
|
---|
| 1044 | PointArray; otherwise returns an empty QPointArray.
|
---|
| 1045 | <p> <p>See also <a href="#asPointArray">asPointArray</a>().
|
---|
| 1046 |
|
---|
| 1047 | <h3 class=fn>const <a href="qrect.html">QRect</a> <a name="toRect"></a>QVariant::toRect () const
|
---|
| 1048 | </h3>
|
---|
| 1049 | Returns the variant as a <a href="qrect.html">QRect</a> if the variant has <a href="#type">type</a>() Rect;
|
---|
| 1050 | otherwise returns an empty rectangle.
|
---|
| 1051 | <p> <p>See also <a href="#asRect">asRect</a>().
|
---|
| 1052 |
|
---|
| 1053 | <h3 class=fn>const <a href="qregion.html">QRegion</a> <a name="toRegion"></a>QVariant::toRegion () const
|
---|
| 1054 | </h3>
|
---|
| 1055 | Returns the variant as a <a href="qregion.html">QRegion</a> if the variant has <a href="#type">type</a>() Region;
|
---|
| 1056 | otherwise returns an empty QRegion.
|
---|
| 1057 | <p> <p>See also <a href="#asRegion">asRegion</a>().
|
---|
| 1058 |
|
---|
| 1059 | <h3 class=fn>const <a href="qsize.html">QSize</a> <a name="toSize"></a>QVariant::toSize () const
|
---|
| 1060 | </h3>
|
---|
| 1061 | Returns the variant as a <a href="qsize.html">QSize</a> if the variant has <a href="#type">type</a>() Size;
|
---|
| 1062 | otherwise returns an invalid size.
|
---|
| 1063 | <p> <p>See also <a href="#asSize">asSize</a>().
|
---|
| 1064 |
|
---|
| 1065 | <h3 class=fn><a href="qsizepolicy.html">QSizePolicy</a> <a name="toSizePolicy"></a>QVariant::toSizePolicy () const
|
---|
| 1066 | </h3>
|
---|
| 1067 | Returns the variant as a <a href="qsizepolicy.html">QSizePolicy</a> if the variant has <a href="#type">type</a>()
|
---|
| 1068 | SizePolicy; otherwise returns an undefined (but legal) size
|
---|
| 1069 | policy.
|
---|
| 1070 |
|
---|
| 1071 | <h3 class=fn>const <a href="qstring.html">QString</a> <a name="toString"></a>QVariant::toString () const
|
---|
| 1072 | </h3>
|
---|
| 1073 | Returns the variant as a <a href="qstring.html">QString</a> if the variant can be cast to
|
---|
| 1074 | String, otherwise returns <a href="qstring.html#QString-null">QString::null</a>.
|
---|
| 1075 | <p> <p>See also <a href="#asString">asString</a>() and <a href="#canCast">canCast</a>().
|
---|
| 1076 |
|
---|
| 1077 | <h3 class=fn>const <a href="qstringlist.html">QStringList</a> <a name="toStringList"></a>QVariant::toStringList () const
|
---|
| 1078 | </h3>
|
---|
| 1079 | Returns the variant as a <a href="qstringlist.html">QStringList</a> if the variant has <a href="#type">type</a>()
|
---|
| 1080 | StringList or List of a type that can be converted to <a href="qstring.html">QString</a>;
|
---|
| 1081 | otherwise returns an empty list.
|
---|
| 1082 | <p> Note that if you want to iterate over the list, you should iterate
|
---|
| 1083 | over a copy, e.g.
|
---|
| 1084 | <pre>
|
---|
| 1085 | <a href="qstringlist.html">QStringList</a> list = myVariant.toStringList();
|
---|
| 1086 | QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
|
---|
| 1087 | while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
|
---|
| 1088 | myProcessing( *it );
|
---|
| 1089 | ++it;
|
---|
| 1090 | }
|
---|
| 1091 | </pre>
|
---|
| 1092 |
|
---|
| 1093 | <p> <p>See also <a href="#asStringList">asStringList</a>().
|
---|
| 1094 |
|
---|
| 1095 | <h3 class=fn>const <a href="qtime.html">QTime</a> <a name="toTime"></a>QVariant::toTime () const
|
---|
| 1096 | </h3>
|
---|
| 1097 | Returns the variant as a <a href="qtime.html">QTime</a> if the variant can be cast to Time;
|
---|
| 1098 | otherwise returns an invalid date.
|
---|
| 1099 | <p> Note that if the <a href="#type">type</a>() is String, CString or ByteArray an invalid
|
---|
| 1100 | time will be returned if the string cannot be parsed as a
|
---|
| 1101 | Qt::ISODate format time.
|
---|
| 1102 | <p> <p>See also <a href="#asTime">asTime</a>().
|
---|
| 1103 |
|
---|
| 1104 | <h3 class=fn>uint <a name="toUInt"></a>QVariant::toUInt ( bool * ok = 0 ) const
|
---|
| 1105 | </h3>
|
---|
| 1106 | Returns the variant as an unsigned int if the variant can be cast
|
---|
| 1107 | to UInt; otherwise returns 0.
|
---|
| 1108 | <p> If <em>ok</em> is non-null: <em>*ok</em> is set to TRUE if the value could be
|
---|
| 1109 | converted to an unsigned int; otherwise <em>*ok</em> is set to FALSE.
|
---|
| 1110 | <p> <p>See also <a href="#asUInt">asUInt</a>() and <a href="#canCast">canCast</a>().
|
---|
| 1111 |
|
---|
| 1112 | <h3 class=fn>Q_ULLONG <a name="toULongLong"></a>QVariant::toULongLong ( bool * ok = 0 ) const
|
---|
| 1113 | </h3>
|
---|
| 1114 | Returns the variant as as an unsigned long long int if the variant
|
---|
| 1115 | can be cast to ULongLong; otherwise returns 0.
|
---|
| 1116 | <p> If <em>ok</em> is non-null: <em>*ok</em> is set to TRUE if the value could be
|
---|
| 1117 | converted to an int; otherwise <em>*ok</em> is set to FALSE.
|
---|
| 1118 | <p> <p>See also <a href="#asULongLong">asULongLong</a>() and <a href="#canCast">canCast</a>().
|
---|
| 1119 |
|
---|
| 1120 | <h3 class=fn><a href="qvariant.html#Type-enum">Type</a> <a name="type"></a>QVariant::type () const
|
---|
| 1121 | </h3>
|
---|
| 1122 |
|
---|
| 1123 | <p> Returns the storage type of the value stored in the variant.
|
---|
| 1124 | Usually it's best to test with <a href="#canCast">canCast</a>() whether the variant can
|
---|
| 1125 | deliver the data type you are interested in.
|
---|
| 1126 |
|
---|
| 1127 | <h3 class=fn>const char * <a name="typeName"></a>QVariant::typeName () const
|
---|
| 1128 | </h3>
|
---|
| 1129 | Returns the name of the type stored in the variant. The returned
|
---|
| 1130 | strings describe the C++ datatype used to store the data: for
|
---|
| 1131 | example, "QFont", "QString", or "QValueList<QVariant>". An Invalid
|
---|
| 1132 | variant returns 0.
|
---|
| 1133 |
|
---|
| 1134 | <h3 class=fn>const char * <a name="typeToName"></a>QVariant::typeToName ( <a href="qvariant.html#Type-enum">Type</a> typ )<tt> [static]</tt>
|
---|
| 1135 | </h3>
|
---|
| 1136 | Converts the enum representation of the storage type, <em>typ</em>, to
|
---|
| 1137 | its string representation.
|
---|
| 1138 |
|
---|
| 1139 | <!-- eof -->
|
---|
| 1140 | <hr><p>
|
---|
| 1141 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 1142 | Copyright © 1995-2007
|
---|
| 1143 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 1144 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 1145 | <td>Copyright © 2007
|
---|
| 1146 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 1147 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 1148 | </table></div></address></body>
|
---|
| 1149 | </html>
|
---|