source: trunk/doc/html/qvariant.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 63.4 KB
Line 
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"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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 &lt;<a href="qvariant-h.html">qvariant.h</a>&gt;</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&nbsp;QVariant&nbsp;&amp;&nbsp;p )</li>
44<li class=fn><a href="#QVariant-3"><b>QVariant</b></a> ( QDataStream&nbsp;&amp;&nbsp;s )</li>
45<li class=fn><a href="#QVariant-4"><b>QVariant</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;val )</li>
46<li class=fn><a href="#QVariant-5"><b>QVariant</b></a> ( const&nbsp;QCString&nbsp;&amp;&nbsp;val )</li>
47<li class=fn><a href="#QVariant-6"><b>QVariant</b></a> ( const&nbsp;char&nbsp;*&nbsp;val )</li>
48<li class=fn><a href="#QVariant-7"><b>QVariant</b></a> ( const&nbsp;QStringList&nbsp;&amp;&nbsp;val )</li>
49<li class=fn><a href="#QVariant-8"><b>QVariant</b></a> ( const&nbsp;QFont&nbsp;&amp;&nbsp;val )</li>
50<li class=fn><a href="#QVariant-9"><b>QVariant</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;val )</li>
51<li class=fn><a href="#QVariant-a"><b>QVariant</b></a> ( const&nbsp;QImage&nbsp;&amp;&nbsp;val )</li>
52<li class=fn><a href="#QVariant-b"><b>QVariant</b></a> ( const&nbsp;QBrush&nbsp;&amp;&nbsp;val )</li>
53<li class=fn><a href="#QVariant-c"><b>QVariant</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;val )</li>
54<li class=fn><a href="#QVariant-d"><b>QVariant</b></a> ( const&nbsp;QRect&nbsp;&amp;&nbsp;val )</li>
55<li class=fn><a href="#QVariant-e"><b>QVariant</b></a> ( const&nbsp;QSize&nbsp;&amp;&nbsp;val )</li>
56<li class=fn><a href="#QVariant-f"><b>QVariant</b></a> ( const&nbsp;QColor&nbsp;&amp;&nbsp;val )</li>
57<li class=fn><a href="#QVariant-g"><b>QVariant</b></a> ( const&nbsp;QPalette&nbsp;&amp;&nbsp;val )</li>
58<li class=fn><a href="#QVariant-h"><b>QVariant</b></a> ( const&nbsp;QColorGroup&nbsp;&amp;&nbsp;val )</li>
59<li class=fn><a href="#QVariant-i"><b>QVariant</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;val )</li>
60<li class=fn><a href="#QVariant-j"><b>QVariant</b></a> ( const&nbsp;QPointArray&nbsp;&amp;&nbsp;val )</li>
61<li class=fn><a href="#QVariant-k"><b>QVariant</b></a> ( const&nbsp;QRegion&nbsp;&amp;&nbsp;val )</li>
62<li class=fn><a href="#QVariant-l"><b>QVariant</b></a> ( const&nbsp;QBitmap&nbsp;&amp;&nbsp;val )</li>
63<li class=fn><a href="#QVariant-m"><b>QVariant</b></a> ( const&nbsp;QCursor&nbsp;&amp;&nbsp;val )</li>
64<li class=fn><a href="#QVariant-n"><b>QVariant</b></a> ( const&nbsp;QDate&nbsp;&amp;&nbsp;val )</li>
65<li class=fn><a href="#QVariant-o"><b>QVariant</b></a> ( const&nbsp;QTime&nbsp;&amp;&nbsp;val )</li>
66<li class=fn><a href="#QVariant-p"><b>QVariant</b></a> ( const&nbsp;QDateTime&nbsp;&amp;&nbsp;val )</li>
67<li class=fn><a href="#QVariant-q"><b>QVariant</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;val )</li>
68<li class=fn><a href="#QVariant-r"><b>QVariant</b></a> ( const&nbsp;QBitArray&nbsp;&amp;&nbsp;val )</li>
69<li class=fn><a href="#QVariant-s"><b>QVariant</b></a> ( const&nbsp;QKeySequence&nbsp;&amp;&nbsp;val )</li>
70<li class=fn><a href="#QVariant-t"><b>QVariant</b></a> ( const&nbsp;QPen&nbsp;&amp;&nbsp;val )</li>
71<li class=fn><a href="#QVariant-u"><b>QVariant</b></a> ( const&nbsp;QValueList&lt;QVariant&gt;&nbsp;&amp;&nbsp;val )</li>
72<li class=fn><a href="#QVariant-v"><b>QVariant</b></a> ( const&nbsp;QMap&lt;QString,&nbsp;QVariant&gt;&nbsp;&amp;&nbsp;val )</li>
73<li class=fn><a href="#QVariant-w"><b>QVariant</b></a> ( int&nbsp;val )</li>
74<li class=fn><a href="#QVariant-x"><b>QVariant</b></a> ( uint&nbsp;val )</li>
75<li class=fn><a href="#QVariant-y"><b>QVariant</b></a> ( Q_LLONG&nbsp;val )</li>
76<li class=fn><a href="#QVariant-z"><b>QVariant</b></a> ( Q_ULLONG&nbsp;val )</li>
77<li class=fn><a href="#QVariant-10"><b>QVariant</b></a> ( bool&nbsp;val, int )</li>
78<li class=fn><a href="#QVariant-11"><b>QVariant</b></a> ( double&nbsp;val )</li>
79<li class=fn><a href="#QVariant-12"><b>QVariant</b></a> ( QSizePolicy&nbsp;val )</li>
80<li class=fn>QVariant &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QVariant&nbsp;&amp;&nbsp;variant )</li>
81<li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const&nbsp;QVariant&nbsp;&amp;&nbsp;v ) const</li>
82<li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const&nbsp;QVariant&nbsp;&amp;&nbsp;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&nbsp;t ) const</li>
86<li class=fn>bool <a href="#cast"><b>cast</b></a> ( Type&nbsp;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&nbsp;*&nbsp;ok = 0 ) const</li>
116<li class=fn>uint <a href="#toUInt"><b>toUInt</b></a> ( bool&nbsp;*&nbsp;ok = 0 ) const</li>
117<li class=fn>Q_LLONG <a href="#toLongLong"><b>toLongLong</b></a> ( bool&nbsp;*&nbsp;ok = 0 ) const</li>
118<li class=fn>Q_ULLONG <a href="#toULongLong"><b>toULongLong</b></a> ( bool&nbsp;*&nbsp;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&nbsp;*&nbsp;ok = 0 ) const</li>
121<li class=fn>const QValueList&lt;QVariant&gt; <a href="#toList"><b>toList</b></a> () const</li>
122<li class=fn>const QMap&lt;QString, QVariant&gt; <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&lt;QString&gt; stringListBegin () const &nbsp;<em>(obsolete)</em></li>
125<li class=fn>QValueListConstIterator&lt;QString&gt; stringListEnd () const &nbsp;<em>(obsolete)</em></li>
126<li class=fn>QValueListConstIterator&lt;QVariant&gt; listBegin () const &nbsp;<em>(obsolete)</em></li>
127<li class=fn>QValueListConstIterator&lt;QVariant&gt; listEnd () const &nbsp;<em>(obsolete)</em></li>
128<li class=fn>QMapConstIterator&lt;QString, QVariant&gt; mapBegin () const &nbsp;<em>(obsolete)</em></li>
129<li class=fn>QMapConstIterator&lt;QString, QVariant&gt; mapEnd () const &nbsp;<em>(obsolete)</em></li>
130<li class=fn>QMapConstIterator&lt;QString, QVariant&gt; mapFind ( const&nbsp;QString&nbsp;&amp;&nbsp;key ) const &nbsp;<em>(obsolete)</em></li>
131<li class=fn>QString &amp; <a href="#asString"><b>asString</b></a> ()</li>
132<li class=fn>QCString &amp; <a href="#asCString"><b>asCString</b></a> ()</li>
133<li class=fn>QStringList &amp; <a href="#asStringList"><b>asStringList</b></a> ()</li>
134<li class=fn>QFont &amp; <a href="#asFont"><b>asFont</b></a> ()</li>
135<li class=fn>QPixmap &amp; <a href="#asPixmap"><b>asPixmap</b></a> ()</li>
136<li class=fn>QImage &amp; <a href="#asImage"><b>asImage</b></a> ()</li>
137<li class=fn>QBrush &amp; <a href="#asBrush"><b>asBrush</b></a> ()</li>
138<li class=fn>QPoint &amp; <a href="#asPoint"><b>asPoint</b></a> ()</li>
139<li class=fn>QRect &amp; <a href="#asRect"><b>asRect</b></a> ()</li>
140<li class=fn>QSize &amp; <a href="#asSize"><b>asSize</b></a> ()</li>
141<li class=fn>QColor &amp; <a href="#asColor"><b>asColor</b></a> ()</li>
142<li class=fn>QPalette &amp; <a href="#asPalette"><b>asPalette</b></a> ()</li>
143<li class=fn>QColorGroup &amp; <a href="#asColorGroup"><b>asColorGroup</b></a> ()</li>
144<li class=fn>QIconSet &amp; <a href="#asIconSet"><b>asIconSet</b></a> ()</li>
145<li class=fn>QPointArray &amp; <a href="#asPointArray"><b>asPointArray</b></a> ()</li>
146<li class=fn>QBitmap &amp; <a href="#asBitmap"><b>asBitmap</b></a> ()</li>
147<li class=fn>QRegion &amp; <a href="#asRegion"><b>asRegion</b></a> ()</li>
148<li class=fn>QCursor &amp; <a href="#asCursor"><b>asCursor</b></a> ()</li>
149<li class=fn>QDate &amp; <a href="#asDate"><b>asDate</b></a> ()</li>
150<li class=fn>QTime &amp; <a href="#asTime"><b>asTime</b></a> ()</li>
151<li class=fn>QDateTime &amp; <a href="#asDateTime"><b>asDateTime</b></a> ()</li>
152<li class=fn>QByteArray &amp; <a href="#asByteArray"><b>asByteArray</b></a> ()</li>
153<li class=fn>QBitArray &amp; <a href="#asBitArray"><b>asBitArray</b></a> ()</li>
154<li class=fn>QKeySequence &amp; <a href="#asKeySequence"><b>asKeySequence</b></a> ()</li>
155<li class=fn>QPen &amp; <a href="#asPen"><b>asPen</b></a> ()</li>
156<li class=fn>int &amp; <a href="#asInt"><b>asInt</b></a> ()</li>
157<li class=fn>uint &amp; <a href="#asUInt"><b>asUInt</b></a> ()</li>
158<li class=fn>Q_LLONG &amp; <a href="#asLongLong"><b>asLongLong</b></a> ()</li>
159<li class=fn>Q_ULLONG &amp; <a href="#asULongLong"><b>asULongLong</b></a> ()</li>
160<li class=fn>bool &amp; <a href="#asBool"><b>asBool</b></a> ()</li>
161<li class=fn>double &amp; <a href="#asDouble"><b>asDouble</b></a> ()</li>
162<li class=fn>QValueList&lt;QVariant&gt; &amp; <a href="#asList"><b>asList</b></a> ()</li>
163<li class=fn>QMap&lt;QString, QVariant&gt; &amp; <a href="#asMap"><b>asMap</b></a> ()</li>
164<li class=fn>QSizePolicy &amp; <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&nbsp;typ )</li>
169<li class=fn>Type <a href="#nameToType"><b>nameToType</b></a> ( const&nbsp;char&nbsp;*&nbsp;name )</li>
170</ul>
171<hr><a name="details"></a><h2>Detailed Description</h2>
172
173
174The 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
179non-default constructors or destructors, most interesting Qt
180classes cannot be used in unions. Without QVariant, this would be
181a 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
183time. (Some type()s are multi-valued, for example a string list.)
184You can find out what type, T, the variant holds, convert it to a
185different type using one of the asT() functions, e.g. <a href="#asSize">asSize</a>(),
186get its value using one of the toT() functions, e.g. <a href="#toSize">toSize</a>(), and
187check 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>
190documentation for a list) are const. If you ask for the stored
191type, they return a copy of the stored object. If you ask for a
192type that can be generated from the stored type, toT() copies and
193converts and leaves the object itself unchanged. If you ask for a
194type that cannot be generated from the stored type, the result
195depends 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
197cases the toT() methods return a <a href="shclass.html#shallow-copy">shallow copy</a>. In almost all cases
198you must make a <a href="shclass.html#deep-copy">deep copy</a> of the returned values before modifying
199them.
200<p> The asT() functions are not const. They do conversion like the
201toT() methods, set the variant to hold the converted value, and
202return 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 &lt;&lt; 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 &lt;&lt; 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 &gt;&gt; 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
227arbitrarily complex data structures of arbitrary types. This is
228very powerful and versatile, but may prove less memory and speed
229efficient than storing specific types in standard data structures.
230<p> QVariant also supports the notion of NULL values, where you have a
231defined 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
245contain.
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>
288Constructs an invalid variant.
289
290<h3 class=fn><a name="QVariant-10"></a>QVariant::QVariant ( bool&nbsp;val, int )
291</h3>
292Constructs a new variant with a boolean value, <em>val</em>. The integer
293argument is a dummy, necessary for compatibility with some
294compilers.
295
296<h3 class=fn><a name="QVariant-11"></a>QVariant::QVariant ( double&nbsp;val )
297</h3>
298Constructs 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>&nbsp;val )
301</h3>
302Constructs a new variant with a size policy value, <em>val</em>.
303
304<h3 class=fn><a name="QVariant-2"></a>QVariant::QVariant ( const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;p )
305</h3>
306Constructs a copy of the variant, <em>p</em>, passed as the argument to
307this 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>
308is 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>&nbsp;&amp;&nbsp;s )
312</h3>
313Reads the variant from the data stream, <em>s</em>.
314
315<h3 class=fn><a name="QVariant-4"></a>QVariant::QVariant ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;val )
316</h3>
317Constructs a new variant with a string value, <em>val</em>.
318
319<h3 class=fn><a name="QVariant-5"></a>QVariant::QVariant ( const&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;val )
320</h3>
321Constructs 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
323constructor, 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&nbsp;char&nbsp;*&nbsp;val )
327</h3>
328Constructs a new variant with a C-string value of <em>val</em> if <em>val</em>
329is 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&nbsp;<a href="qstringlist.html">QStringList</a>&nbsp;&amp;&nbsp;val )
333</h3>
334Constructs a new variant with a string list value, <em>val</em>.
335
336<h3 class=fn><a name="QVariant-8"></a>QVariant::QVariant ( const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;val )
337</h3>
338Constructs a new variant with a font value, <em>val</em>.
339
340<h3 class=fn><a name="QVariant-9"></a>QVariant::QVariant ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;val )
341</h3>
342Constructs a new variant with a pixmap value, <em>val</em>.
343
344<h3 class=fn><a name="QVariant-a"></a>QVariant::QVariant ( const&nbsp;<a href="qimage.html">QImage</a>&nbsp;&amp;&nbsp;val )
345</h3>
346Constructs 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
348changing the image you've passed later on.
349
350<h3 class=fn><a name="QVariant-b"></a>QVariant::QVariant ( const&nbsp;<a href="qbrush.html">QBrush</a>&nbsp;&amp;&nbsp;val )
351</h3>
352Constructs a new variant with a brush value, <em>val</em>.
353
354<h3 class=fn><a name="QVariant-c"></a>QVariant::QVariant ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;val )
355</h3>
356Constructs a new variant with a point value, <em>val</em>.
357
358<h3 class=fn><a name="QVariant-d"></a>QVariant::QVariant ( const&nbsp;<a href="qrect.html">QRect</a>&nbsp;&amp;&nbsp;val )
359</h3>
360Constructs a new variant with a rect value, <em>val</em>.
361
362<h3 class=fn><a name="QVariant-e"></a>QVariant::QVariant ( const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;val )
363</h3>
364Constructs a new variant with a size value, <em>val</em>.
365
366<h3 class=fn><a name="QVariant-f"></a>QVariant::QVariant ( const&nbsp;<a href="qcolor.html">QColor</a>&nbsp;&amp;&nbsp;val )
367</h3>
368Constructs a new variant with a color value, <em>val</em>.
369
370<h3 class=fn><a name="QVariant-g"></a>QVariant::QVariant ( const&nbsp;<a href="qpalette.html">QPalette</a>&nbsp;&amp;&nbsp;val )
371</h3>
372Constructs a new variant with a color palette value, <em>val</em>.
373
374<h3 class=fn><a name="QVariant-h"></a>QVariant::QVariant ( const&nbsp;<a href="qcolorgroup.html">QColorGroup</a>&nbsp;&amp;&nbsp;val )
375</h3>
376Constructs a new variant with a color group value, <em>val</em>.
377
378<h3 class=fn><a name="QVariant-i"></a>QVariant::QVariant ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;val )
379</h3>
380Constructs a new variant with an icon set value, <em>val</em>.
381
382<h3 class=fn><a name="QVariant-j"></a>QVariant::QVariant ( const&nbsp;<a href="qpointarray.html">QPointArray</a>&nbsp;&amp;&nbsp;val )
383</h3>
384Constructs 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
387intend changing the point array you've passed later on.
388
389<h3 class=fn><a name="QVariant-k"></a>QVariant::QVariant ( const&nbsp;<a href="qregion.html">QRegion</a>&nbsp;&amp;&nbsp;val )
390</h3>
391Constructs a new variant with a region value, <em>val</em>.
392
393<h3 class=fn><a name="QVariant-l"></a>QVariant::QVariant ( const&nbsp;<a href="qbitmap.html">QBitmap</a>&nbsp;&amp;&nbsp;val )
394</h3>
395Constructs a new variant with a bitmap value, <em>val</em>.
396
397<h3 class=fn><a name="QVariant-m"></a>QVariant::QVariant ( const&nbsp;<a href="qcursor.html">QCursor</a>&nbsp;&amp;&nbsp;val )
398</h3>
399Constructs a new variant with a cursor value, <em>val</em>.
400
401<h3 class=fn><a name="QVariant-n"></a>QVariant::QVariant ( const&nbsp;<a href="qdate.html">QDate</a>&nbsp;&amp;&nbsp;val )
402</h3>
403Constructs a new variant with a date value, <em>val</em>.
404
405<h3 class=fn><a name="QVariant-o"></a>QVariant::QVariant ( const&nbsp;<a href="qtime.html">QTime</a>&nbsp;&amp;&nbsp;val )
406</h3>
407Constructs a new variant with a time value, <em>val</em>.
408
409<h3 class=fn><a name="QVariant-p"></a>QVariant::QVariant ( const&nbsp;<a href="qdatetime.html">QDateTime</a>&nbsp;&amp;&nbsp;val )
410</h3>
411Constructs a new variant with a date/time value, <em>val</em>.
412
413<h3 class=fn><a name="QVariant-q"></a>QVariant::QVariant ( const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;val )
414</h3>
415Constructs a new variant with a bytearray value, <em>val</em>.
416
417<h3 class=fn><a name="QVariant-r"></a>QVariant::QVariant ( const&nbsp;<a href="qbitarray.html">QBitArray</a>&nbsp;&amp;&nbsp;val )
418</h3>
419Constructs a new variant with a bitarray value, <em>val</em>.
420
421<h3 class=fn><a name="QVariant-s"></a>QVariant::QVariant ( const&nbsp;<a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp;&nbsp;val )
422</h3>
423Constructs a new variant with a key sequence value, <em>val</em>.
424
425<h3 class=fn><a name="QVariant-t"></a>QVariant::QVariant ( const&nbsp;<a href="qpen.html">QPen</a>&nbsp;&amp;&nbsp;val )
426</h3>
427Constructs a new variant with a pen value, <em>val</em>.
428
429<h3 class=fn><a name="QVariant-u"></a>QVariant::QVariant ( const&nbsp;<a href="qvaluelist.html">QValueList</a>&lt;QVariant&gt;&nbsp;&amp;&nbsp;val )
430</h3>
431Constructs a new variant with a list value, <em>val</em>.
432
433<h3 class=fn><a name="QVariant-v"></a>QVariant::QVariant ( const&nbsp;<a href="qmap.html">QMap</a>&lt;QString,&nbsp;QVariant&gt;&nbsp;&amp;&nbsp;val )
434</h3>
435Constructs a new variant with a map of QVariants, <em>val</em>.
436
437<h3 class=fn><a name="QVariant-w"></a>QVariant::QVariant ( int&nbsp;val )
438</h3>
439Constructs a new variant with an integer value, <em>val</em>.
440
441<h3 class=fn><a name="QVariant-x"></a>QVariant::QVariant ( uint&nbsp;val )
442</h3>
443Constructs 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&nbsp;val )
446</h3>
447Constructs 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&nbsp;val )
450</h3>
451Constructs 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>
455Destroys the QVariant and the contained object.
456<p> Note that subclasses that reimplement <a href="#clear">clear</a>() should reimplement
457the destructor to call clear(). This destructor calls clear(), but
458because it is the destructor, <a href="#clear">QVariant::clear</a>() is called rather
459than a subclass's clear().
460
461<h3 class=fn><a href="qbitarray.html">QBitArray</a>&nbsp;&amp; <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
465not 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>&nbsp;&amp; <a name="asBitmap"></a>QVariant::asBitmap ()
470</h3>
471
472<p> Tries to convert the variant to hold a bitmap value. If that is
473not 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 &amp; <a name="asBool"></a>QVariant::asBool ()
478</h3>
479Returns the variant's value as bool reference.
480
481<h3 class=fn><a href="qbrush.html">QBrush</a>&nbsp;&amp; <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
485possible 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>&nbsp;&amp; <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
493is 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>&nbsp;&amp; <a name="asCString"></a>QVariant::asCString ()
498</h3>
499
500<p> Tries to convert the variant to hold a string value. If that is
501not 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>&nbsp;&amp; <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
509not 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>&nbsp;&amp; <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
517is not possible the variant is set to a color group of all black
518colors.
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>&nbsp;&amp; <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
526not 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>&nbsp;&amp; <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
534possible 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>&nbsp;&amp; <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
542not 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 &amp; <a name="asDouble"></a>QVariant::asDouble ()
547</h3>
548Returns the variant's value as double reference.
549
550<h3 class=fn><a href="qfont.html">QFont</a>&nbsp;&amp; <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
554possible 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>&nbsp;&amp; <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
562not 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>&nbsp;&amp; <a name="asImage"></a>QVariant::asImage ()
567</h3>
568
569<p> Tries to convert the variant to hold an image value. If that is
570not 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 &amp; <a name="asInt"></a>QVariant::asInt ()
575</h3>
576Returns the variant's value as int reference.
577
578<h3 class=fn><a href="qkeysequence.html">QKeySequence</a>&nbsp;&amp; <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
582is 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>&lt;QVariant&gt;&nbsp;&amp; <a name="asList"></a>QVariant::asList ()
587</h3>
588Returns the variant's value as variant list reference.
589<p> Note that if you want to iterate over the list, you should iterate
590over a copy, e.g.
591<pre>
592 <a href="qvaluelist.html">QValueList</a>&lt;QVariant&gt; list = myVariant.asList();
593 QValueList&lt;QVariant&gt;::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 &amp; <a name="asLongLong"></a>QVariant::asLongLong ()
602</h3>
603Returns the variant's value as long long reference.
604
605<h3 class=fn><a href="qmap.html">QMap</a>&lt;QString,&nbsp;QVariant&gt;&nbsp;&amp; <a name="asMap"></a>QVariant::asMap ()
606</h3>
607Returns the variant's value as variant map reference.
608<p> Note that if you want to iterate over the map, you should iterate
609over a copy, e.g.
610<pre>
611 <a href="qmap.html">QMap</a>&lt;QString, QVariant&gt; map = myVariant.asMap();
612 QMap&lt;QString, QVariant&gt;::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>&nbsp;&amp; <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
624not 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>&nbsp;&amp; <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
631is 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>&nbsp;&amp; <a name="asPixmap"></a>QVariant::asPixmap ()
636</h3>
637
638<p> Tries to convert the variant to hold a pixmap value. If that is
639not 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>&nbsp;&amp; <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
647possible 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>&nbsp;&amp; <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
655is 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>&nbsp;&amp; <a name="asRect"></a>QVariant::asRect ()
660</h3>
661
662<p> Tries to convert the variant to hold a rectangle value. If that is
663not 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>&nbsp;&amp; <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
671not 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>&nbsp;&amp; <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
679possible 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>&nbsp;&amp; <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
687fails, the variant is set to an arbitrary (valid) size policy.
688
689<h3 class=fn><a href="qstring.html">QString</a>&nbsp;&amp; <a name="asString"></a>QVariant::asString ()
690</h3>
691
692<p> Tries to convert the variant to hold a string value. If that is
693not 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>&nbsp;&amp; <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
701is 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
704iterate 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>&nbsp;&amp; <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
720possible 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 &amp; <a name="asUInt"></a>QVariant::asUInt ()
725</h3>
726Returns the variant's value as unsigned int reference.
727
728<h3 class=fn>Q_ULLONG &amp; <a name="asULongLong"></a>QVariant::asULongLong ()
729</h3>
730Returns 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>&nbsp;t ) const
733</h3>
734Returns TRUE if the variant's type can be cast to the requested
735type, <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
750something 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,
752Time, 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>&nbsp;t )
762</h3>
763Casts the variant to the requested type. If the cast cannot be
764done, the variant is set to the default value of the requested
765type (e.g. an empty string if the requested type <em>t</em> is
766QVariant::String, an empty point array if the requested type <em>t</em>
767is QVariant::PointArray, etc). Returns TRUE if the current type of
768the 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>
773Convert this variant to type Invalid and free up any resources
774used.
775
776<h3 class=fn>bool <a name="isNull"></a>QVariant::isNull () const
777</h3>
778Returns 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
784QVariant::Invalid; otherwise returns FALSE.
785
786<h3 class=fn><a href="qvaluelistconstiterator.html">QValueListConstIterator</a>&lt;QVariant&gt; <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
791type is appropriate; otherwise returns a null iterator.
792
793<h3 class=fn><a href="qvaluelistconstiterator.html">QValueListConstIterator</a>&lt;QVariant&gt; <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
798appropriate; otherwise returns a null iterator.
799
800<h3 class=fn><a href="qmapconstiterator.html">QMapConstIterator</a>&lt;QString,&nbsp;QVariant&gt; <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
805type is appropriate; otherwise returns a null iterator.
806
807<h3 class=fn><a href="qmapconstiterator.html">QMapConstIterator</a>&lt;QString,&nbsp;QVariant&gt; <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
812appropriate; otherwise returns a null iterator.
813
814<h3 class=fn><a href="qmapconstiterator.html">QMapConstIterator</a>&lt;QString,&nbsp;QVariant&gt; <a name="mapFind"></a>QVariant::mapFind ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;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
819the variant's type is appropriate and <em>key</em> is a valid key;
820otherwise returns a null iterator.
821
822<h3 class=fn><a href="qvariant.html#Type-enum">Type</a> <a name="nameToType"></a>QVariant::nameToType ( const&nbsp;char&nbsp;*&nbsp;name )<tt> [static]</tt>
823</h3>
824Converts 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
826representation, 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&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;v ) const
829</h3>
830Compares this QVariant with <em>v</em> and returns TRUE if they are not
831equal; otherwise returns FALSE.
832
833<h3 class=fn><a href="qvariant.html">QVariant</a>&nbsp;&amp; <a name="operator-eq"></a>QVariant::operator= ( const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;variant )
834</h3>
835Assigns 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
837holds 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
838performed.
839
840<h3 class=fn>bool <a name="operator-eq-eq"></a>QVariant::operator== ( const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;v ) const
841</h3>
842Compares this QVariant with <em>v</em> and returns TRUE if they are
843equal; otherwise returns FALSE.
844
845<h3 class=fn><a href="qvaluelistconstiterator.html">QValueListConstIterator</a>&lt;QString&gt; <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
850variant's type is StringList; otherwise returns a null iterator.
851
852<h3 class=fn><a href="qvaluelistconstiterator.html">QValueListConstIterator</a>&lt;QString&gt; <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
857StringList; otherwise returns a null iterator.
858
859<h3 class=fn>const&nbsp;<a href="qbitarray.html">QBitArray</a> <a name="toBitArray"></a>QVariant::toBitArray () const
860</h3>
861Returns the variant as a <a href="qbitarray.html">QBitArray</a> if the variant has <a href="#type">type</a>()
862BitArray; otherwise returns an empty bitarray.
863<p> <p>See also <a href="#asBitArray">asBitArray</a>().
864
865<h3 class=fn>const&nbsp;<a href="qbitmap.html">QBitmap</a> <a name="toBitmap"></a>QVariant::toBitmap () const
866</h3>
867Returns the variant as a <a href="qbitmap.html">QBitmap</a> if the variant has <a href="#type">type</a>() Bitmap;
868otherwise 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>
873Returns the variant as a bool if the variant can be cast to Bool;
874otherWise returns FALSE.
875<p> Returns TRUE if the variant has a numeric type and its value is
876non-zero, or if the variant has type String, ByteArray or CString
877and its lower-case content is not empty, "0" or "false"; otherwise
878returns FALSE.
879<p> <p>See also <a href="#asBool">asBool</a>() and <a href="#canCast">canCast</a>().
880
881<h3 class=fn>const&nbsp;<a href="qbrush.html">QBrush</a> <a name="toBrush"></a>QVariant::toBrush () const
882</h3>
883Returns the variant as a <a href="qbrush.html">QBrush</a> if the variant has <a href="#type">type</a>() Brush;
884otherwise returns a default brush (with all black colors).
885<p> <p>See also <a href="#asBrush">asBrush</a>().
886
887<h3 class=fn>const&nbsp;<a href="qbytearray.html">QByteArray</a> <a name="toByteArray"></a>QVariant::toByteArray () const
888</h3>
889Returns the variant as a <a href="qbytearray.html">QByteArray</a> if the variant can be cast to
890a 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&nbsp;<a href="qcstring.html">QCString</a> <a name="toCString"></a>QVariant::toCString () const
894</h3>
895Returns the variant as a <a href="qcstring.html">QCString</a> if the variant can be cast to a
896CString; 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&nbsp;<a href="qcolor.html">QColor</a> <a name="toColor"></a>QVariant::toColor () const
900</h3>
901Returns the variant as a <a href="qcolor.html">QColor</a> if the variant can be cast to Color;
902otherwise 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&nbsp;<a href="qcolorgroup.html">QColorGroup</a> <a name="toColorGroup"></a>QVariant::toColorGroup () const
906</h3>
907Returns the variant as a <a href="qcolorgroup.html">QColorGroup</a> if the variant has <a href="#type">type</a>()
908ColorGroup; otherwise returns a completely black color group.
909<p> <p>See also <a href="#asColorGroup">asColorGroup</a>().
910
911<h3 class=fn>const&nbsp;<a href="qcursor.html">QCursor</a> <a name="toCursor"></a>QVariant::toCursor () const
912</h3>
913Returns the variant as a <a href="qcursor.html">QCursor</a> if the variant has <a href="#type">type</a>() Cursor;
914otherwise returns the default arrow cursor.
915<p> <p>See also <a href="#asCursor">asCursor</a>().
916
917<h3 class=fn>const&nbsp;<a href="qdate.html">QDate</a> <a name="toDate"></a>QVariant::toDate () const
918</h3>
919Returns the variant as a <a href="qdate.html">QDate</a> if the variant can be cast to Date;
920otherwise returns an invalid date.
921<p> Note that if the <a href="#type">type</a>() is String, CString or ByteArray an invalid
922date will be returned if the string cannot be parsed as a
923Qt::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&nbsp;<a href="qdatetime.html">QDateTime</a> <a name="toDateTime"></a>QVariant::toDateTime () const
927</h3>
928Returns the variant as a <a href="qdatetime.html">QDateTime</a> if the variant can be cast to
929DateTime; otherwise returns an invalid QDateTime.
930<p> Note that if the <a href="#type">type</a>() is String, CString or ByteArray an invalid
931QDateTime will be returned if the string cannot be parsed as a
932Qt::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&nbsp;*&nbsp;ok = 0 ) const
936</h3>
937Returns the variant as a double if the variant can be cast to
938Double; 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
940converted 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&nbsp;<a href="qfont.html">QFont</a> <a name="toFont"></a>QVariant::toFont () const
944</h3>
945Returns the variant as a <a href="qfont.html">QFont</a> if the variant can be cast to Font;
946otherwise 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&nbsp;<a href="qiconset.html">QIconSet</a> <a name="toIconSet"></a>QVariant::toIconSet () const
950</h3>
951Returns the variant as a <a href="qiconset.html">QIconSet</a> if the variant has <a href="#type">type</a>()
952IconSet; otherwise returns an icon set of null pixmaps.
953<p> <p>See also <a href="#asIconSet">asIconSet</a>().
954
955<h3 class=fn>const&nbsp;<a href="qimage.html">QImage</a> <a name="toImage"></a>QVariant::toImage () const
956</h3>
957Returns the variant as a <a href="qimage.html">QImage</a> if the variant has <a href="#type">type</a>() Image;
958otherwise 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&nbsp;*&nbsp;ok = 0 ) const
962</h3>
963Returns the variant as an int if the variant can be cast to Int;
964otherwise returns 0.
965<p> If <em>ok</em> is non-null: <em>*ok</em> is set to TRUE if the value could be
966converted 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&nbsp;<a href="qkeysequence.html">QKeySequence</a> <a name="toKeySequence"></a>QVariant::toKeySequence () const
970</h3>
971Returns the variant as a <a href="qkeysequence.html">QKeySequence</a> if the variant can be cast
972to 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&nbsp;<a href="qvaluelist.html">QValueList</a>&lt;QVariant&gt; <a name="toList"></a>QVariant::toList () const
976</h3>
977Returns 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
980over a copy, e.g.
981<pre>
982 <a href="qvaluelist.html">QValueList</a>&lt;QVariant&gt; list = myVariant.toList();
983 QValueList&lt;QVariant&gt;::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&nbsp;*&nbsp;ok = 0 ) const
993</h3>
994Returns the variant as a long long int if the variant can be cast
995to 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
997converted 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&nbsp;<a href="qmap.html">QMap</a>&lt;QString,&nbsp;QVariant&gt; <a name="toMap"></a>QVariant::toMap () const
1001</h3>
1002Returns 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
1005over a copy, e.g.
1006<pre>
1007 <a href="qmap.html">QMap</a>&lt;QString, QVariant&gt; map = myVariant.toMap();
1008 QMap&lt;QString, QVariant&gt;::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&nbsp;<a href="qpalette.html">QPalette</a> <a name="toPalette"></a>QVariant::toPalette () const
1018</h3>
1019Returns the variant as a <a href="qpalette.html">QPalette</a> if the variant has <a href="#type">type</a>()
1020Palette; otherwise returns a completely black palette.
1021<p> <p>See also <a href="#asPalette">asPalette</a>().
1022
1023<h3 class=fn>const&nbsp;<a href="qpen.html">QPen</a> <a name="toPen"></a>QVariant::toPen () const
1024</h3>
1025Returns the variant as a <a href="qpen.html">QPen</a> if the variant has <a href="#type">type</a>()
1026Pen; otherwise returns an empty QPen.
1027<p> <p>See also <a href="#asPen">asPen</a>().
1028
1029<h3 class=fn>const&nbsp;<a href="qpixmap.html">QPixmap</a> <a name="toPixmap"></a>QVariant::toPixmap () const
1030</h3>
1031Returns the variant as a <a href="qpixmap.html">QPixmap</a> if the variant has <a href="#type">type</a>() Pixmap;
1032otherwise returns a null pixmap.
1033<p> <p>See also <a href="#asPixmap">asPixmap</a>().
1034
1035<h3 class=fn>const&nbsp;<a href="qpoint.html">QPoint</a> <a name="toPoint"></a>QVariant::toPoint () const
1036</h3>
1037Returns the variant as a <a href="qpoint.html">QPoint</a> if the variant has <a href="#type">type</a>() Point;
1038otherwise returns a point (0, 0).
1039<p> <p>See also <a href="#asPoint">asPoint</a>().
1040
1041<h3 class=fn>const&nbsp;<a href="qpointarray.html">QPointArray</a> <a name="toPointArray"></a>QVariant::toPointArray () const
1042</h3>
1043Returns the variant as a <a href="qpointarray.html">QPointArray</a> if the variant has <a href="#type">type</a>()
1044PointArray; otherwise returns an empty QPointArray.
1045<p> <p>See also <a href="#asPointArray">asPointArray</a>().
1046
1047<h3 class=fn>const&nbsp;<a href="qrect.html">QRect</a> <a name="toRect"></a>QVariant::toRect () const
1048</h3>
1049Returns the variant as a <a href="qrect.html">QRect</a> if the variant has <a href="#type">type</a>() Rect;
1050otherwise returns an empty rectangle.
1051<p> <p>See also <a href="#asRect">asRect</a>().
1052
1053<h3 class=fn>const&nbsp;<a href="qregion.html">QRegion</a> <a name="toRegion"></a>QVariant::toRegion () const
1054</h3>
1055Returns the variant as a <a href="qregion.html">QRegion</a> if the variant has <a href="#type">type</a>() Region;
1056otherwise returns an empty QRegion.
1057<p> <p>See also <a href="#asRegion">asRegion</a>().
1058
1059<h3 class=fn>const&nbsp;<a href="qsize.html">QSize</a> <a name="toSize"></a>QVariant::toSize () const
1060</h3>
1061Returns the variant as a <a href="qsize.html">QSize</a> if the variant has <a href="#type">type</a>() Size;
1062otherwise 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>
1067Returns the variant as a <a href="qsizepolicy.html">QSizePolicy</a> if the variant has <a href="#type">type</a>()
1068SizePolicy; otherwise returns an undefined (but legal) size
1069policy.
1070
1071<h3 class=fn>const&nbsp;<a href="qstring.html">QString</a> <a name="toString"></a>QVariant::toString () const
1072</h3>
1073Returns the variant as a <a href="qstring.html">QString</a> if the variant can be cast to
1074String, 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&nbsp;<a href="qstringlist.html">QStringList</a> <a name="toStringList"></a>QVariant::toStringList () const
1078</h3>
1079Returns the variant as a <a href="qstringlist.html">QStringList</a> if the variant has <a href="#type">type</a>()
1080StringList or List of a type that can be converted to <a href="qstring.html">QString</a>;
1081otherwise returns an empty list.
1082<p> Note that if you want to iterate over the list, you should iterate
1083over 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&nbsp;<a href="qtime.html">QTime</a> <a name="toTime"></a>QVariant::toTime () const
1096</h3>
1097Returns the variant as a <a href="qtime.html">QTime</a> if the variant can be cast to Time;
1098otherwise returns an invalid date.
1099<p> Note that if the <a href="#type">type</a>() is String, CString or ByteArray an invalid
1100time will be returned if the string cannot be parsed as a
1101Qt::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&nbsp;*&nbsp;ok = 0 ) const
1105</h3>
1106Returns the variant as an unsigned int if the variant can be cast
1107to 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
1109converted 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&nbsp;*&nbsp;ok = 0 ) const
1113</h3>
1114Returns the variant as as an unsigned long long int if the variant
1115can 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
1117converted 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.
1124Usually it's best to test with <a href="#canCast">canCast</a>() whether the variant can
1125deliver the data type you are interested in.
1126
1127<h3 class=fn>const char * <a name="typeName"></a>QVariant::typeName () const
1128</h3>
1129Returns the name of the type stored in the variant. The returned
1130strings describe the C++ datatype used to store the data: for
1131example, "QFont", "QString", or "QValueList<QVariant>". An Invalid
1132variant returns 0.
1133
1134<h3 class=fn>const char * <a name="typeToName"></a>QVariant::typeToName ( <a href="qvariant.html#Type-enum">Type</a>&nbsp;typ )<tt> [static]</tt>
1135</h3>
1136Converts the enum representation of the storage type, <em>typ</em>, to
1137its string representation.
1138
1139<!-- eof -->
1140<hr><p>
1141This file is part of the <a href="index.html">Qt toolkit</a>.
1142Copyright &copy; 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 &copy; 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>
Note: See TracBrowser for help on using the repository browser.