source: trunk/doc/html/qvariant-h.html

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

reference documentation added

File size: 12.6 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/include/qvariant.h:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>qvariant.h Include File</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.h</h1>
33
34<p>This is the verbatim text of the qvariant.h include file. It is provided only for illustration; the copyright remains with Trolltech.
35<hr>
36<pre>
37/****************************************************************************
38** $Id: qvariant-h.html 2051 2007-02-21 10:04:20Z chehrlic $
39**
40** Definition of QVariant class
41**
42** Created : 990414
43**
44** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
45**
46** This file is part of the kernel module of the Qt GUI Toolkit.
47**
48** This file may be distributed under the terms of the Q Public License
49** as defined by Trolltech ASA of Norway and appearing in the file
50** LICENSE.QPL included in the packaging of this file.
51**
52** This file may be distributed and/or modified under the terms of the
53** GNU General Public License version 2 as published by the Free Software
54** Foundation and appearing in the file LICENSE.GPL included in the
55** packaging of this file.
56**
57** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
58** licenses may use this file in accordance with the Qt Commercial License
59** Agreement provided with the Software.
60**
61** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
62** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
63**
64** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
65** information about Qt Commercial License Agreements.
66** See http://www.trolltech.com/qpl/ for QPL licensing information.
67** See http://www.trolltech.com/gpl/ for GPL licensing information.
68**
69** Contact info@trolltech.com if any conditions of this licensing are
70** not clear to you.
71**
72**********************************************************************/
73
74#ifndef QVARIANT_H
75#define QVARIANT_H
76
77#ifndef QT_H
78#include "qstring.h"
79#endif // QT_H
80
81#ifndef QT_NO_VARIANT
82class QString;
83class QCString;
84class QFont;
85class QPixmap;
86class QBrush;
87class QRect;
88class QPoint;
89class QImage;
90class QSize;
91class QColor;
92class QPalette;
93class QColorGroup;
94class QIconSet;
95class QDataStream;
96class QPointArray;
97class QRegion;
98class QBitmap;
99class QCursor;
100class QStringList;
101class QSizePolicy;
102class QDate;
103class QTime;
104class QDateTime;
105class QBitArray;
106class QKeySequence;
107class QPen;
108// Some headers rejected after QVariant declaration for GCC 2.7.* compatibility
109class QVariant;
110#ifndef QT_NO_TEMPLATE_VARIANT
111template &lt;class T&gt; class QValueList;
112template &lt;class T&gt; class QValueListConstIterator;
113template &lt;class T&gt; class QValueListNode;
114template &lt;class Key, class T&gt; class QMap;
115template &lt;class Key, class T&gt; class QMapConstIterator;
116#endif
117
118class Q_EXPORT QVariant
119{
120public:
121 enum Type {
122 Invalid,
123 Map,
124 List,
125 String,
126 StringList,
127 Font,
128 Pixmap,
129 Brush,
130 Rect,
131 Size,
132 Color,
133 Palette,
134 ColorGroup,
135 IconSet,
136 Point,
137 Image,
138 Int,
139 UInt,
140 Bool,
141 Double,
142 CString,
143 PointArray,
144 Region,
145 Bitmap,
146 Cursor,
147 SizePolicy,
148 Date,
149 Time,
150 DateTime,
151 ByteArray,
152 BitArray,
153 KeySequence,
154 Pen,
155 LongLong,
156 ULongLong
157 };
158
159 QVariant();
160 ~QVariant();
161 QVariant( const QVariant&amp; );
162#ifndef QT_NO_DATASTREAM
163 QVariant( QDataStream&amp; s );
164#endif
165 QVariant( const QString&amp; );
166 QVariant( const QCString&amp; );
167 QVariant( const char* );
168#ifndef QT_NO_STRINGLIST
169 QVariant( const QStringList&amp; );
170#endif
171 QVariant( const QFont&amp; );
172 QVariant( const QPixmap&amp; );
173 QVariant( const QImage&amp; );
174 QVariant( const QBrush&amp; );
175 QVariant( const QPoint&amp; );
176 QVariant( const QRect&amp; );
177 QVariant( const QSize&amp; );
178 QVariant( const QColor&amp; );
179 QVariant( const QPalette&amp; );
180 QVariant( const QColorGroup&amp; );
181 QVariant( const QIconSet&amp; );
182 QVariant( const QPointArray&amp; );
183 QVariant( const QRegion&amp; );
184 QVariant( const QBitmap&amp; );
185 QVariant( const QCursor&amp; );
186 QVariant( const QDate&amp; );
187 QVariant( const QTime&amp; );
188 QVariant( const QDateTime&amp; );
189 QVariant( const QByteArray&amp; );
190 QVariant( const QBitArray&amp; );
191#ifndef QT_NO_ACCEL
192 QVariant( const QKeySequence&amp; );
193#endif
194 QVariant( const QPen&amp; );
195#ifndef QT_NO_TEMPLATE_VARIANT
196 QVariant( const QValueList&lt;QVariant&gt;&amp; );
197 QVariant( const QMap&lt;QString,QVariant&gt;&amp; );
198#endif
199 QVariant( int );
200 QVariant( uint );
201 QVariant( Q_LLONG );
202 QVariant( Q_ULLONG );
203 // ### Problems on some compilers ?
204 QVariant( bool, int );
205 QVariant( double );
206 QVariant( QSizePolicy );
207
208 QVariant&amp; operator= ( const QVariant&amp; );
209 bool operator==( const QVariant&amp; ) const;
210 bool operator!=( const QVariant&amp; ) const;
211
212 Type type() const;
213 const char* typeName() const;
214
215 bool canCast( Type ) const;
216 bool cast( Type );
217
218 bool isValid() const;
219 bool isNull() const;
220
221 void clear();
222
223 const QString toString() const;
224 const QCString toCString() const;
225#ifndef QT_NO_STRINGLIST
226 const QStringList toStringList() const;
227#endif
228 const QFont toFont() const;
229 const QPixmap toPixmap() const;
230 const QImage toImage() const;
231 const QBrush toBrush() const;
232 const QPoint toPoint() const;
233 const QRect toRect() const;
234 const QSize toSize() const;
235 const QColor toColor() const;
236 const QPalette toPalette() const;
237 const QColorGroup toColorGroup() const;
238 const QIconSet toIconSet() const;
239 const QPointArray toPointArray() const;
240 const QBitmap toBitmap() const;
241 const QRegion toRegion() const;
242 const QCursor toCursor() const;
243 const QDate toDate() const;
244 const QTime toTime() const;
245 const QDateTime toDateTime() const;
246 const QByteArray toByteArray() const;
247 const QBitArray toBitArray() const;
248#ifndef QT_NO_ACCEL
249 const QKeySequence toKeySequence() const;
250#endif
251 const QPen toPen() const;
252 int toInt( bool * ok=0 ) const;
253 uint toUInt( bool * ok=0 ) const;
254 Q_LLONG toLongLong( bool * ok=0 ) const;
255 Q_ULLONG toULongLong( bool * ok=0 ) const;
256 bool toBool() const;
257 double toDouble( bool * ok=0 ) const;
258#ifndef QT_NO_TEMPLATE_VARIANT
259 const QValueList&lt;QVariant&gt; toList() const;
260 const QMap&lt;QString,QVariant&gt; toMap() const;
261#endif
262 QSizePolicy toSizePolicy() const;
263
264#ifndef QT_NO_TEMPLATE_VARIANT
265 QValueListConstIterator&lt;QString&gt; stringListBegin() const;
266 QValueListConstIterator&lt;QString&gt; stringListEnd() const;
267 QValueListConstIterator&lt;QVariant&gt; listBegin() const;
268 QValueListConstIterator&lt;QVariant&gt; listEnd() const;
269 QMapConstIterator&lt;QString,QVariant&gt; mapBegin() const;
270 QMapConstIterator&lt;QString,QVariant&gt; mapEnd() const;
271 QMapConstIterator&lt;QString,QVariant&gt; mapFind( const QString&amp; ) const;
272#endif
273 QString&amp; asString();
274 QCString&amp; asCString();
275#ifndef QT_NO_STRINGLIST
276 QStringList&amp; asStringList();
277#endif
278 QFont&amp; asFont();
279 QPixmap&amp; asPixmap();
280 QImage&amp; asImage();
281 QBrush&amp; asBrush();
282 QPoint&amp; asPoint();
283 QRect&amp; asRect();
284 QSize&amp; asSize();
285 QColor&amp; asColor();
286 QPalette&amp; asPalette();
287 QColorGroup&amp; asColorGroup();
288 QIconSet&amp; asIconSet();
289 QPointArray&amp; asPointArray();
290 QBitmap&amp; asBitmap();
291 QRegion&amp; asRegion();
292 QCursor&amp; asCursor();
293 QDate&amp; asDate();
294 QTime&amp; asTime();
295 QDateTime&amp; asDateTime();
296 QByteArray&amp; asByteArray();
297 QBitArray&amp; asBitArray();
298#ifndef QT_NO_ACCEL
299 QKeySequence&amp; asKeySequence();
300#endif
301 QPen&amp; asPen();
302 int&amp; asInt();
303 uint&amp; asUInt();
304 Q_LLONG&amp; asLongLong();
305 Q_ULLONG&amp; asULongLong();
306 bool&amp; asBool();
307 double&amp; asDouble();
308#ifndef QT_NO_TEMPLATE_VARIANT
309 QValueList&lt;QVariant&gt;&amp; asList();
310 QMap&lt;QString,QVariant&gt;&amp; asMap();
311#endif
312 QSizePolicy&amp; asSizePolicy();
313
314#ifndef QT_NO_DATASTREAM
315 void load( QDataStream&amp; );
316 void save( QDataStream&amp; ) const;
317#endif
318 static const char* typeToName( Type typ );
319 static Type nameToType( const char* name );
320
321private:
322 void detach();
323
324 class Private : public QShared
325 {
326 public:
327 Private();
328 Private( Private* );
329 ~Private();
330
331 void clear();
332
333 Type typ;
334 union
335 {
336 uint u;
337 int i;
338 Q_LLONG ll;
339 Q_ULLONG ull;
340 bool b;
341 double d;
342 void *ptr;
343 } value;
344 uint is_null : 1; // ## 4.0 merge with typ
345 };
346
347 Private* d;
348
349public:
350 void* rawAccess( void* ptr = 0, Type typ = Invalid, bool deepCopy = FALSE );
351};
352
353// down here for GCC 2.7.* compatibility
354#ifndef QT_H
355#include "qvaluelist.h"
356#include "qstringlist.h"
357#include "qmap.h"
358#endif // QT_H
359
360inline QVariant::Type QVariant::type() const
361{
362 return d-&gt;typ;
363}
364
365inline bool QVariant::isValid() const
366{
367 return (d-&gt;typ != Invalid);
368}
369
370#ifndef QT_NO_TEMPLATE_VARIANT
371inline QValueListConstIterator&lt;QString&gt; QVariant::stringListBegin() const
372{
373 if ( d-&gt;typ != StringList )
374 return QValueListConstIterator&lt;QString&gt;();
375 return ((const QStringList*)d-&gt;value.ptr)-&gt;begin();
376}
377
378inline QValueListConstIterator&lt;QString&gt; QVariant::stringListEnd() const
379{
380 if ( d-&gt;typ != StringList )
381 return QValueListConstIterator&lt;QString&gt;();
382 return ((const QStringList*)d-&gt;value.ptr)-&gt;end();
383}
384
385inline QValueListConstIterator&lt;QVariant&gt; QVariant::listBegin() const
386{
387 if ( d-&gt;typ != List )
388 return QValueListConstIterator&lt;QVariant&gt;();
389 return ((const QValueList&lt;QVariant&gt;*)d-&gt;value.ptr)-&gt;begin();
390}
391
392inline QValueListConstIterator&lt;QVariant&gt; QVariant::listEnd() const
393{
394 if ( d-&gt;typ != List )
395 return QValueListConstIterator&lt;QVariant&gt;();
396 return ((const QValueList&lt;QVariant&gt;*)d-&gt;value.ptr)-&gt;end();
397}
398
399inline QMapConstIterator&lt;QString,QVariant&gt; QVariant::mapBegin() const
400{
401 if ( d-&gt;typ != Map )
402 return QMapConstIterator&lt;QString,QVariant&gt;();
403 return ((const QMap&lt;QString,QVariant&gt;*)d-&gt;value.ptr)-&gt;begin();
404}
405
406inline QMapConstIterator&lt;QString,QVariant&gt; QVariant::mapEnd() const
407{
408 if ( d-&gt;typ != Map )
409 return QMapConstIterator&lt;QString,QVariant&gt;();
410 return ((const QMap&lt;QString,QVariant&gt;*)d-&gt;value.ptr)-&gt;end();
411}
412
413inline QMapConstIterator&lt;QString,QVariant&gt; QVariant::mapFind( const QString&amp; key ) const
414{
415 if ( d-&gt;typ != Map )
416 return QMapConstIterator&lt;QString,QVariant&gt;();
417 return ((const QMap&lt;QString,QVariant&gt;*)d-&gt;value.ptr)-&gt;find( key );
418}
419#endif
420
421#ifndef QT_NO_DATASTREAM
422Q_EXPORT QDataStream&amp; operator&gt;&gt; ( QDataStream&amp; s, QVariant&amp; p );
423Q_EXPORT QDataStream&amp; operator&lt;&lt; ( QDataStream&amp; s, const QVariant&amp; p );
424Q_EXPORT QDataStream&amp; operator&gt;&gt; ( QDataStream&amp; s, QVariant::Type&amp; p );
425Q_EXPORT QDataStream&amp; operator&lt;&lt; ( QDataStream&amp; s, const QVariant::Type p );
426#endif
427
428#endif //QT_NO_VARIANT
429#endif // QVARIANT_H
430</pre>
431<!-- eof -->
432<p><address><hr><div align=center>
433<table width=100% cellspacing=0 border=0><tr>
434<td>Copyright &copy; 2007
435<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
436<td align=right><div align=right>Qt 3.3.8</div>
437</table></div></address></body>
438</html>
Note: See TracBrowser for help on using the repository browser.