1QVariant(3qt)                                                    QVariant(3qt)
2
3
4

NAME

6       QVariant - Acts like a union for the most common Qt data types
7

SYNOPSIS

9       #include <qvariant.h>
10
11   Public Members
12       enum Type { Invalid, Map, List, String, StringList, Font, Pixmap,
13           Brush, Rect, Size, Color, Palette, ColorGroup, IconSet, Point,
14           Image, Int, UInt, Bool, Double, CString, PointArray, Region,
15           Bitmap, Cursor, SizePolicy, Date, Time, DateTime, ByteArray,
16           BitArray, KeySequence, Pen, LongLong, ULongLong }
17       QVariant ()
18       ~QVariant ()
19       QVariant ( const QVariant & p )
20       QVariant ( QDataStream & s )
21       QVariant ( const QString & val )
22       QVariant ( const QCString & val )
23       QVariant ( const char * val )
24       QVariant ( const QStringList & val )
25       QVariant ( const QFont & val )
26       QVariant ( const QPixmap & val )
27       QVariant ( const QImage & val )
28       QVariant ( const QBrush & val )
29       QVariant ( const QPoint & val )
30       QVariant ( const QRect & val )
31       QVariant ( const QSize & val )
32       QVariant ( const QColor & val )
33       QVariant ( const QPalette & val )
34       QVariant ( const QColorGroup & val )
35       QVariant ( const QIconSet & val )
36       QVariant ( const QPointArray & val )
37       QVariant ( const QRegion & val )
38       QVariant ( const QBitmap & val )
39       QVariant ( const QCursor & val )
40       QVariant ( const QDate & val )
41       QVariant ( const QTime & val )
42       QVariant ( const QDateTime & val )
43       QVariant ( const QByteArray & val )
44       QVariant ( const QBitArray & val )
45       QVariant ( const QKeySequence & val )
46       QVariant ( const QPen & val )
47       QVariant ( const QValueList<QVariant> & val )
48       QVariant ( const QMap<QString, QVariant> & val )
49       QVariant ( int val )
50       QVariant ( uint val )
51       QVariant ( Q_LLONG val )
52       QVariant ( Q_ULLONG val )
53       QVariant ( bool val, int )
54       QVariant ( double val )
55       QVariant ( QSizePolicy val )
56       QVariant & operator= ( const QVariant & variant )
57       bool operator== ( const QVariant & v ) const
58       bool operator!= ( const QVariant & v ) const
59       Type type () const
60       const char * typeName () const
61       bool canCast ( Type t ) const
62       bool cast ( Type t )
63       bool isValid () const
64       bool isNull () const
65       void clear ()
66       const QString toString () const
67       const QCString toCString () const
68       const QStringList toStringList () const
69       const QFont toFont () const
70       const QPixmap toPixmap () const
71       const QImage toImage () const
72       const QBrush toBrush () const
73       const QPoint toPoint () const
74       const QRect toRect () const
75       const QSize toSize () const
76       const QColor toColor () const
77       const QPalette toPalette () const
78       const QColorGroup toColorGroup () const
79       const QIconSet toIconSet () const
80       const QPointArray toPointArray () const
81       const QBitmap toBitmap () const
82       const QRegion toRegion () const
83       const QCursor toCursor () const
84       const QDate toDate () const
85       const QTime toTime () const
86       const QDateTime toDateTime () const
87       const QByteArray toByteArray () const
88       const QBitArray toBitArray () const
89       const QKeySequence toKeySequence () const
90       const QPen toPen () const
91       int toInt ( bool * ok = 0 ) const
92       uint toUInt ( bool * ok = 0 ) const
93       Q_LLONG toLongLong ( bool * ok = 0 ) const
94       Q_ULLONG toULongLong ( bool * ok = 0 ) const
95       bool toBool () const
96       double toDouble ( bool * ok = 0 ) const
97       const QValueList<QVariant> toList () const
98       const QMap<QString, QVariant> toMap () const
99       QSizePolicy toSizePolicy () const
100       QValueListConstIterator<QString> stringListBegin () const  (obsolete)
101       QValueListConstIterator<QString> stringListEnd () const  (obsolete)
102       QValueListConstIterator<QVariant> listBegin () const  (obsolete)
103       QValueListConstIterator<QVariant> listEnd () const  (obsolete)
104       QMapConstIterator<QString, QVariant> mapBegin () const  (obsolete)
105       QMapConstIterator<QString, QVariant> mapEnd () const  (obsolete)
106       QMapConstIterator<QString, QVariant> mapFind ( const QString & key )
107           const  (obsolete)
108       QString & asString ()
109       QCString & asCString ()
110       QStringList & asStringList ()
111       QFont & asFont ()
112       QPixmap & asPixmap ()
113       QImage & asImage ()
114       QBrush & asBrush ()
115       QPoint & asPoint ()
116       QRect & asRect ()
117       QSize & asSize ()
118       QColor & asColor ()
119       QPalette & asPalette ()
120       QColorGroup & asColorGroup ()
121       QIconSet & asIconSet ()
122       QPointArray & asPointArray ()
123       QBitmap & asBitmap ()
124       QRegion & asRegion ()
125       QCursor & asCursor ()
126       QDate & asDate ()
127       QTime & asTime ()
128       QDateTime & asDateTime ()
129       QByteArray & asByteArray ()
130       QBitArray & asBitArray ()
131       QKeySequence & asKeySequence ()
132       QPen & asPen ()
133       int & asInt ()
134       uint & asUInt ()
135       Q_LLONG & asLongLong ()
136       Q_ULLONG & asULongLong ()
137       bool & asBool ()
138       double & asDouble ()
139       QValueList<QVariant> & asList ()
140       QMap<QString, QVariant> & asMap ()
141       QSizePolicy & asSizePolicy ()
142
143   Static Public Members
144       const char * typeToName ( Type typ )
145       Type nameToType ( const char * name )
146

DESCRIPTION

148       The QVariant class acts like a union for the most common Qt data types.
149
150       Because C++ forbids unions from including types that have non-default
151       constructors or destructors, most interesting Qt classes cannot be used
152       in unions. Without QVariant, this would be a problem for
153       QObject::property() and for database work, etc.
154
155       A QVariant object holds a single value of a single type() at a time.
156       (Some type()s are multi-valued, for example a string list.) You can
157       find out what type, T, the variant holds, convert it to a different
158       type using one of the asT() functions, e.g. asSize(), get its value
159       using one of the toT() functions, e.g. toSize(), and check whether the
160       type can be converted to a particular type using canCast().
161
162       The methods named toT() (for any supported T, see the Type
163       documentation for a list) are const. If you ask for the stored type,
164       they return a copy of the stored object. If you ask for a type that can
165       be generated from the stored type, toT() copies and converts and leaves
166       the object itself unchanged. If you ask for a type that cannot be
167       generated from the stored type, the result depends on the type (see the
168       function documentation for details).
169
170       Note that three data types supported by QVariant are explicitly shared,
171       namely QImage, QPointArray, and QCString, and in these cases the toT()
172       methods return a shallow copy. In almost all cases you must make a deep
173       copy of the returned values before modifying them.
174
175       The asT() functions are not const. They do conversion like the toT()
176       methods, set the variant to hold the converted value, and return a
177       reference to the new contents of the variant.
178
179       Here is some example code to demonstrate the use of QVariant:
180
181           QDataStream out(...);
182           QVariant v(123);          // The variant now contains an int
183           int x = v.toInt();        // x = 123
184           out << v;                 // Writes a type tag and an int to out
185           v = QVariant("hello");    // The variant now contains a QCString
186           v = QVariant(tr("hello"));// The variant now contains a QString
187           int y = v.toInt();        // y = 0 since v cannot be converted to an int
188           QString s = v.toString(); // s = tr("hello")  (see QObject::tr())
189           out << v;                 // Writes a type tag and a QString to out
190           ...
191           QDataStream in(...);      // (opening the previously written stream)
192           in >> v;                  // Reads an Int variant
193           int z = v.toInt();        // z = 123
194           qDebug("Type is %s",      // prints "Type is int"
195                   v.typeName());
196           v.asInt() += 100;         // The variant now hold the value 223.
197           v = QVariant( QStringList() );
198           v.asStringList().append( "Hello" );
199
200       You can even store QValueList<QVariant>s and QMap<QString,QVariant>s in
201       a variant, so you can easily construct arbitrarily complex data
202       structures of arbitrary types. This is very powerful and versatile, but
203       may prove less memory and speed efficient than storing specific types
204       in standard data structures.
205
206       QVariant also supports the notion of NULL values, where you have a
207       defined type with no value set.
208
209           QVariant x, y( QString() ), z( QString("") );
210           x.asInt();
211           // x.isNull() == TRUE, y.isNull() == TRUE, z.isNull() == FALSE
212
213       See the Collection Classes.
214
215       See also Miscellaneous Classes and Object Model.
216
217   Member Type Documentation

QVariant::Type

219       This enum type defines the types of variable that a QVariant can
220       contain.
221
222       QVariant::Invalid - no type
223
224       QVariant::BitArray - a QBitArray
225
226       QVariant::ByteArray - a QByteArray
227
228       QVariant::Bitmap - a QBitmap
229
230       QVariant::Bool - a bool
231
232       QVariant::Brush - a QBrush
233
234       QVariant::Color - a QColor
235
236       QVariant::ColorGroup - a QColorGroup
237
238       QVariant::Cursor - a QCursor
239
240       QVariant::Date - a QDate
241
242       QVariant::DateTime - a QDateTime
243
244       QVariant::Double - a double
245
246       QVariant::Font - a QFont
247
248       QVariant::IconSet - a QIconSet
249
250       QVariant::Image - a QImage
251
252       QVariant::Int - an int
253
254       QVariant::KeySequence - a QKeySequence
255
256       QVariant::List - a QValueList<QVariant>
257
258       QVariant::LongLong - a long long
259
260       QVariant::ULongLong - an unsigned long long
261
262       QVariant::Map - a QMap<QString,QVariant>
263
264       QVariant::Palette - a QPalette
265
266       QVariant::Pen - a QPen
267
268       QVariant::Pixmap - a QPixmap
269
270       QVariant::Point - a QPoint
271
272       QVariant::PointArray - a QPointArray
273
274       QVariant::Rect - a QRect
275
276       QVariant::Region - a QRegion
277
278       QVariant::Size - a QSize
279
280       QVariant::SizePolicy - a QSizePolicy
281
282       QVariant::String - a QString
283
284       QVariant::CString - a QCString
285
286       QVariant::StringList - a QStringList
287
288       QVariant::Time - a QTime
289
290       QVariant::UInt - an unsigned int
291
292       Note that Qt's definition of bool depends on the compiler. qglobal.h
293       has the system-dependent definition of bool.
294

MEMBER FUNCTION DOCUMENTATION

QVariant::QVariant ()

297       Constructs an invalid variant.
298

QVariant::QVariant ( bool val, int )

300       Constructs a new variant with a boolean value, val. The integer
301       argument is a dummy, necessary for compatibility with some compilers.
302

QVariant::QVariant ( double val )

304       Constructs a new variant with a floating point value, val.
305

QVariant::QVariant ( QSizePolicy val )

307       Constructs a new variant with a size policy value, val.
308

QVariant::QVariant ( const QVariant & p )

310       Constructs a copy of the variant, p, passed as the argument to this
311       constructor. Usually this is a deep copy, but a shallow copy is made if
312       the stored data type is explicitly shared, as e.g. QImage is.
313

QVariant::QVariant ( QDataStream & s )

315       Reads the variant from the data stream, s.
316

QVariant::QVariant ( const QString & val )

318       Constructs a new variant with a string value, val.
319

QVariant::QVariant ( const QCString & val )

321       Constructs a new variant with a C-string value, val.
322
323       If you want to modify the QCString after you've passed it to this
324       constructor, we recommend passing a deep copy (see QCString::copy()).
325

QVariant::QVariant ( const char * val )

327       Constructs a new variant with a C-string value of val if val is non-
328       null. The variant creates a deep copy of val.
329
330       If val is null, the resulting variant has type Invalid.
331

QVariant::QVariant ( const QStringList & val )

333       Constructs a new variant with a string list value, val.
334

QVariant::QVariant ( const QFont & val )

336       Constructs a new variant with a font value, val.
337

QVariant::QVariant ( const QPixmap & val )

339       Constructs a new variant with a pixmap value, val.
340

QVariant::QVariant ( const QImage & val )

342       Constructs a new variant with an image value, val.
343
344       Because QImage is explicitly shared, you may need to pass a deep copy
345       to the variant using QImage::copy(), e.g. if you intend changing the
346       image you've passed later on.
347

QVariant::QVariant ( const QBrush & val )

349       Constructs a new variant with a brush value, val.
350

QVariant::QVariant ( const QPoint & val )

352       Constructs a new variant with a point value, val.
353

QVariant::QVariant ( const QRect & val )

355       Constructs a new variant with a rect value, val.
356

QVariant::QVariant ( const QSize & val )

358       Constructs a new variant with a size value, val.
359

QVariant::QVariant ( const QColor & val )

361       Constructs a new variant with a color value, val.
362

QVariant::QVariant ( const QPalette & val )

364       Constructs a new variant with a color palette value, val.
365

QVariant::QVariant ( const QColorGroup & val )

367       Constructs a new variant with a color group value, val.
368

QVariant::QVariant ( const QIconSet & val )

370       Constructs a new variant with an icon set value, val.
371

QVariant::QVariant ( const QPointArray & val )

373       Constructs a new variant with a point array value, val.
374
375       Because QPointArray is explicitly shared, you may need to pass a deep
376       copy to the variant using QPointArray::copy(), e.g. if you intend
377       changing the point array you've passed later on.
378

QVariant::QVariant ( const QRegion & val )

380       Constructs a new variant with a region value, val.
381

QVariant::QVariant ( const QBitmap & val )

383       Constructs a new variant with a bitmap value, val.
384

QVariant::QVariant ( const QCursor & val )

386       Constructs a new variant with a cursor value, val.
387

QVariant::QVariant ( const QDate & val )

389       Constructs a new variant with a date value, val.
390

QVariant::QVariant ( const QTime & val )

392       Constructs a new variant with a time value, val.
393

QVariant::QVariant ( const QDateTime & val )

395       Constructs a new variant with a date/time value, val.
396

QVariant::QVariant ( const QByteArray & val )

398       Constructs a new variant with a bytearray value, val.
399

QVariant::QVariant ( const QBitArray & val )

401       Constructs a new variant with a bitarray value, val.
402

QVariant::QVariant ( const QKeySequence & val )

404       Constructs a new variant with a key sequence value, val.
405

QVariant::QVariant ( const QPen & val )

407       Constructs a new variant with a pen value, val.
408

QVariant::QVariant ( const QValueList<QVariant> & val )

410       Constructs a new variant with a list value, val.
411

QVariant::QVariant ( const QMap<QString, QVariant> & val )

413       Constructs a new variant with a map of QVariants, val.
414

QVariant::QVariant ( int val )

416       Constructs a new variant with an integer value, val.
417

QVariant::QVariant ( uint val )

419       Constructs a new variant with an unsigned integer value, val.
420

QVariant::QVariant ( Q_LLONG val )

422       Constructs a new variant with a long long integer value, val.
423

QVariant::QVariant ( Q_ULLONG val )

425       Constructs a new variant with an unsigned long long integer value, val.
426

QVariant::~QVariant ()

428       Destroys the QVariant and the contained object.
429
430       Note that subclasses that reimplement clear() should reimplement the
431       destructor to call clear(). This destructor calls clear(), but because
432       it is the destructor, QVariant::clear() is called rather than a
433       subclass's clear().
434

QBitArray & QVariant::asBitArray ()

436       Tries to convert the variant to hold a QBitArray value. If that is not
437       possible then the variant is set to an empty bitarray.
438
439       Returns a reference to the stored bitarray.
440
441       See also toBitArray().
442

QBitmap & QVariant::asBitmap ()

444       Tries to convert the variant to hold a bitmap value. If that is not
445       possible the variant is set to a null bitmap.
446
447       Returns a reference to the stored bitmap.
448
449       See also toBitmap().
450

bool & QVariant::asBool ()

452       Returns the variant's value as bool reference.
453

QBrush & QVariant::asBrush ()

455       Tries to convert the variant to hold a brush value. If that is not
456       possible the variant is set to a default black brush.
457
458       Returns a reference to the stored brush.
459
460       See also toBrush().
461

QByteArray & QVariant::asByteArray ()

463       Tries to convert the variant to hold a QByteArray value. If that is not
464       possible then the variant is set to an empty bytearray.
465
466       Returns a reference to the stored bytearray.
467
468       See also toByteArray().
469

QCString & QVariant::asCString ()

471       Tries to convert the variant to hold a string value. If that is not
472       possible the variant is set to an empty string.
473
474       Returns a reference to the stored string.
475
476       See also toCString().
477

QColor & QVariant::asColor ()

479       Tries to convert the variant to hold a QColor value. If that is not
480       possible the variant is set to an invalid color.
481
482       Returns a reference to the stored color.
483
484       See also toColor() and QColor::isValid().
485

QColorGroup & QVariant::asColorGroup ()

487       Tries to convert the variant to hold a QColorGroup value. If that is
488       not possible the variant is set to a color group of all black colors.
489
490       Returns a reference to the stored color group.
491
492       See also toColorGroup().
493

QCursor & QVariant::asCursor ()

495       Tries to convert the variant to hold a QCursor value. If that is not
496       possible the variant is set to a default arrow cursor.
497
498       Returns a reference to the stored cursor.
499
500       See also toCursor().
501

QDate & QVariant::asDate ()

503       Tries to convert the variant to hold a QDate value. If that is not
504       possible then the variant is set to an invalid date.
505
506       Returns a reference to the stored date.
507
508       See also toDate().
509

QDateTime & QVariant::asDateTime ()

511       Tries to convert the variant to hold a QDateTime value. If that is not
512       possible then the variant is set to an invalid date/time.
513
514       Returns a reference to the stored date/time.
515
516       See also toDateTime().
517

double & QVariant::asDouble ()

519       Returns the variant's value as double reference.
520

QFont & QVariant::asFont ()

522       Tries to convert the variant to hold a QFont. If that is not possible
523       the variant is set to the application's default font.
524
525       Returns a reference to the stored font.
526
527       See also toFont().
528

QIconSet & QVariant::asIconSet ()

530       Tries to convert the variant to hold a QIconSet value. If that is not
531       possible the variant is set to an empty iconset.
532
533       Returns a reference to the stored iconset.
534
535       See also toIconSet().
536

QImage & QVariant::asImage ()

538       Tries to convert the variant to hold an image value. If that is not
539       possible the variant is set to a null image.
540
541       Returns a reference to the stored image.
542
543       See also toImage().
544

int & QVariant::asInt ()

546       Returns the variant's value as int reference.
547

QKeySequence & QVariant::asKeySequence ()

549       Tries to convert the variant to hold a QKeySequence value. If that is
550       not possible then the variant is set to an empty key sequence.
551
552       Returns a reference to the stored key sequence.
553
554       See also toKeySequence().
555

QValueList<QVariant> & QVariant::asList ()

557       Returns the variant's value as variant list reference.
558
559       Note that if you want to iterate over the list, you should iterate over
560       a copy, e.g.
561
562           QValueList<QVariant> list = myVariant.asList();
563           QValueList<QVariant>::Iterator it = list.begin();
564           while( it != list.end() ) {
565               myProcessing( *it );
566               ++it;
567           }
568

Q_LLONG & QVariant::asLongLong ()

570       Returns the variant's value as long long reference.
571

QMap<QString, QVariant> & QVariant::asMap ()

573       Returns the variant's value as variant map reference.
574
575       Note that if you want to iterate over the map, you should iterate over
576       a copy, e.g.
577
578           QMap<QString, QVariant> map = myVariant.asMap();
579           QMap<QString, QVariant>::Iterator it = map.begin();
580           while( it != map.end() ) {
581               myProcessing( *it );
582               ++it;
583           }
584

QPalette & QVariant::asPalette ()

586       Tries to convert the variant to hold a QPalette value. If that is not
587       possible the variant is set to a palette of black colors.
588
589       Returns a reference to the stored palette.
590
591       See also toString().
592

QPen & QVariant::asPen ()

594       Tries to convert the variant to hold a QPen value. If that is not
595       possible then the variant is set to an empty pen.
596
597       Returns a reference to the stored pen.
598
599       See also toPen().
600

QPixmap & QVariant::asPixmap ()

602       Tries to convert the variant to hold a pixmap value. If that is not
603       possible the variant is set to a null pixmap.
604
605       Returns a reference to the stored pixmap.
606
607       See also toPixmap().
608

QPoint & QVariant::asPoint ()

610       Tries to convert the variant to hold a point value. If that is not
611       possible the variant is set to a (0, 0) point.
612
613       Returns a reference to the stored point.
614
615       See also toPoint().
616

QPointArray & QVariant::asPointArray ()

618       Tries to convert the variant to hold a QPointArray value. If that is
619       not possible the variant is set to an empty point array.
620
621       Returns a reference to the stored point array.
622
623       See also toPointArray().
624

QRect & QVariant::asRect ()

626       Tries to convert the variant to hold a rectangle value. If that is not
627       possible the variant is set to an empty rectangle.
628
629       Returns a reference to the stored rectangle.
630
631       See also toRect().
632

QRegion & QVariant::asRegion ()

634       Tries to convert the variant to hold a QRegion value. If that is not
635       possible the variant is set to a null region.
636
637       Returns a reference to the stored region.
638
639       See also toRegion().
640

QSize & QVariant::asSize ()

642       Tries to convert the variant to hold a QSize value. If that is not
643       possible the variant is set to an invalid size.
644
645       Returns a reference to the stored size.
646
647       See also toSize() and QSize::isValid().
648

QSizePolicy & QVariant::asSizePolicy ()

650       Tries to convert the variant to hold a QSizePolicy value. If that
651       fails, the variant is set to an arbitrary (valid) size policy.
652

QString & QVariant::asString ()

654       Tries to convert the variant to hold a string value. If that is not
655       possible the variant is set to an empty string.
656
657       Returns a reference to the stored string.
658
659       See also toString().
660

QStringList & QVariant::asStringList ()

662       Tries to convert the variant to hold a QStringList value. If that is
663       not possible the variant is set to an empty string list.
664
665       Returns a reference to the stored string list.
666
667       Note that if you want to iterate over the list, you should iterate over
668       a copy, e.g.
669
670           QStringList list = myVariant.asStringList();
671           QStringList::Iterator it = list.begin();
672           while( it != list.end() ) {
673               myProcessing( *it );
674               ++it;
675           }
676
677       See also toStringList().
678

QTime & QVariant::asTime ()

680       Tries to convert the variant to hold a QTime value. If that is not
681       possible then the variant is set to an invalid time.
682
683       Returns a reference to the stored time.
684
685       See also toTime().
686

uint & QVariant::asUInt ()

688       Returns the variant's value as unsigned int reference.
689

Q_ULLONG & QVariant::asULongLong ()

691       Returns the variant's value as unsigned long long reference.
692

bool QVariant::canCast ( Type t ) const

694       Returns TRUE if the variant's type can be cast to the requested type,
695       t. Such casting is done automatically when calling the toInt(),
696       toBool(), ... or asInt(), asBool(), ... methods.
697
698       The following casts are done automatically: <center>.nf
699
700       </center>
701

bool QVariant::cast ( Type t )

703       Casts the variant to the requested type. If the cast cannot be done,
704       the variant is set to the default value of the requested type (e.g. an
705       empty string if the requested type t is QVariant::String, an empty
706       point array if the requested type t is QVariant::PointArray, etc).
707       Returns TRUE if the current type of the variant was successfully cast;
708       otherwise returns FALSE.
709
710       See also canCast().
711

void QVariant::clear ()

713       Convert this variant to type Invalid and free up any resources used.
714

bool QVariant::isNull () const

716       Returns TRUE if this is a NULL variant, FALSE otherwise.
717

bool QVariant::isValid () const

719       Returns TRUE if the storage type of this variant is not
720       QVariant::Invalid; otherwise returns FALSE.
721

QValueListConstIterator<QVariant> QVariant::listBegin () const

723       This function is obsolete. It is provided to keep old source working.
724       We strongly advise against using it in new code.
725
726       Returns an iterator to the first item in the list if the variant's type
727       is appropriate; otherwise returns a null iterator.
728

QValueListConstIterator<QVariant> QVariant::listEnd () const

730       This function is obsolete. It is provided to keep old source working.
731       We strongly advise against using it in new code.
732
733       Returns the end iterator for the list if the variant's type is
734       appropriate; otherwise returns a null iterator.
735

QMapConstIterator<QString, QVariant> QVariant::mapBegin () const

737       This function is obsolete. It is provided to keep old source working.
738       We strongly advise against using it in new code.
739
740       Returns an iterator to the first item in the map, if the variant's type
741       is appropriate; otherwise returns a null iterator.
742

QMapConstIterator<QString, QVariant> QVariant::mapEnd () const

744       This function is obsolete. It is provided to keep old source working.
745       We strongly advise against using it in new code.
746
747       Returns the end iterator for the map, if the variant's type is
748       appropriate; otherwise returns a null iterator.
749

QMapConstIterator<QString, QVariant> QVariant::mapFind ( const QString & key )

751       const
752       This function is obsolete. It is provided to keep old source working.
753       We strongly advise against using it in new code.
754
755       Returns an iterator to the item in the map with key as key, if the
756       variant's type is appropriate and key is a valid key; otherwise returns
757       a null iterator.
758

Type QVariant::nameToType ( const char * name ) [static]

760       Converts the string representation of the storage type given in name,
761       to its enum representation.
762
763       If the string representation cannot be converted to any enum
764       representation, the variant is set to Invalid.
765

bool QVariant::operator!= ( const QVariant & v ) const

767       Compares this QVariant with v and returns TRUE if they are not equal;
768       otherwise returns FALSE.
769

QVariant & QVariant::operator= ( const QVariant & variant )

771       Assigns the value of the variant variant to this variant.
772
773       This is a deep copy of the variant, but note that if the variant holds
774       an explicitly shared type such as QImage, a shallow copy is performed.
775

bool QVariant::operator== ( const QVariant & v ) const

777       Compares this QVariant with v and returns TRUE if they are equal;
778       otherwise returns FALSE.
779

QValueListConstIterator<QString> QVariant::stringListBegin () const

781       This function is obsolete. It is provided to keep old source working.
782       We strongly advise against using it in new code.
783
784       Returns an iterator to the first string in the list if the variant's
785       type is StringList; otherwise returns a null iterator.
786

QValueListConstIterator<QString> QVariant::stringListEnd () const

788       This function is obsolete. It is provided to keep old source working.
789       We strongly advise against using it in new code.
790
791       Returns the end iterator for the list if the variant's type is
792       StringList; otherwise returns a null iterator.
793

const QBitArray QVariant::toBitArray () const

795       Returns the variant as a QBitArray if the variant has type() BitArray;
796       otherwise returns an empty bitarray.
797
798       See also asBitArray().
799

const QBitmap QVariant::toBitmap () const

801       Returns the variant as a QBitmap if the variant has type() Bitmap;
802       otherwise returns a null QBitmap.
803
804       See also asBitmap().
805

bool QVariant::toBool () const

807       Returns the variant as a bool if the variant can be cast to Bool;
808       otherWise returns FALSE.
809
810       Returns TRUE if the variant has a numeric type and its value is non-
811       zero, or if the variant has type String, ByteArray or CString and its
812       lower-case content is not empty, "0" or "false"; otherwise returns
813       FALSE.
814
815       See also asBool() and canCast().
816

const QBrush QVariant::toBrush () const

818       Returns the variant as a QBrush if the variant has type() Brush;
819       otherwise returns a default brush (with all black colors).
820
821       See also asBrush().
822

const QByteArray QVariant::toByteArray () const

824       Returns the variant as a QByteArray if the variant can be cast to a
825       ByteArray; otherwise returns an empty bytearray.
826
827       See also asByteArray() and canCast().
828

const QCString QVariant::toCString () const

830       Returns the variant as a QCString if the variant can be cast to a
831       CString; otherwise returns 0.
832
833       See also asCString() and canCast().
834

const QColor QVariant::toColor () const

836       Returns the variant as a QColor if the variant can be cast to Color;
837       otherwise returns an invalid color.
838
839       See also asColor() and canCast().
840

const QColorGroup QVariant::toColorGroup () const

842       Returns the variant as a QColorGroup if the variant has type()
843       ColorGroup; otherwise returns a completely black color group.
844
845       See also asColorGroup().
846

const QCursor QVariant::toCursor () const

848       Returns the variant as a QCursor if the variant has type() Cursor;
849       otherwise returns the default arrow cursor.
850
851       See also asCursor().
852

const QDate QVariant::toDate () const

854       Returns the variant as a QDate if the variant can be cast to Date;
855       otherwise returns an invalid date.
856
857       Note that if the type() is String, CString or ByteArray an invalid date
858       will be returned if the string cannot be parsed as a Qt::ISODate format
859       date.
860
861       See also asDate() and canCast().
862

const QDateTime QVariant::toDateTime () const

864       Returns the variant as a QDateTime if the variant can be cast to
865       DateTime; otherwise returns an invalid QDateTime.
866
867       Note that if the type() is String, CString or ByteArray an invalid
868       QDateTime will be returned if the string cannot be parsed as a
869       Qt::ISODate format date/time.
870
871       See also asDateTime().
872

double QVariant::toDouble ( bool * ok = 0 ) const

874       Returns the variant as a double if the variant can be cast to Double;
875       otherwise returns 0.0.
876
877       If ok is non-null: *ok is set to TRUE if the value could be converted
878       to a double; otherwise *ok is set to FALSE.
879
880       See also asDouble() and canCast().
881

const QFont QVariant::toFont () const

883       Returns the variant as a QFont if the variant can be cast to Font;
884       otherwise returns the application's default font.
885
886       See also asFont() and canCast().
887

const QIconSet QVariant::toIconSet () const

889       Returns the variant as a QIconSet if the variant has type() IconSet;
890       otherwise returns an icon set of null pixmaps.
891
892       See also asIconSet().
893

const QImage QVariant::toImage () const

895       Returns the variant as a QImage if the variant has type() Image;
896       otherwise returns a null image.
897
898       See also asImage().
899

int QVariant::toInt ( bool * ok = 0 ) const

901       Returns the variant as an int if the variant can be cast to Int;
902       otherwise returns 0.
903
904       If ok is non-null: *ok is set to TRUE if the value could be converted
905       to an int; otherwise *ok is set to FALSE.
906
907       See also asInt() and canCast().
908

const QKeySequence QVariant::toKeySequence () const

910       Returns the variant as a QKeySequence if the variant can be cast to a
911       KeySequence; otherwise returns an empty key sequence.
912
913       See also asKeySequence() and canCast().
914

const QValueList<QVariant> QVariant::toList () const

916       Returns the variant as a QValueList<QVariant> if the variant has type()
917       List or StringList; otherwise returns an empty list.
918
919       Note that if you want to iterate over the list, you should iterate over
920       a copy, e.g.
921
922           QValueList<QVariant> list = myVariant.toList();
923           QValueList<QVariant>::Iterator it = list.begin();
924           while( it != list.end() ) {
925               myProcessing( *it );
926               ++it;
927           }
928
929       See also asList().
930

Q_LLONG QVariant::toLongLong ( bool * ok = 0 ) const

932       Returns the variant as a long long int if the variant can be cast to
933       LongLong; otherwise returns 0.
934
935       If ok is non-null: *ok is set to TRUE if the value could be converted
936       to an int; otherwise *ok is set to FALSE.
937
938       See also asLongLong() and canCast().
939

const QMap<QString, QVariant> QVariant::toMap () const

941       Returns the variant as a QMap<QString,QVariant> if the variant has
942       type() Map; otherwise returns an empty map.
943
944       Note that if you want to iterate over the map, you should iterate over
945       a copy, e.g.
946
947           QMap<QString, QVariant> map = myVariant.toMap();
948           QMap<QString, QVariant>::Iterator it = map.begin();
949           while( it != map.end() ) {
950               myProcessing( *it );
951               ++it;
952           }
953
954       See also asMap().
955

const QPalette QVariant::toPalette () const

957       Returns the variant as a QPalette if the variant has type() Palette;
958       otherwise returns a completely black palette.
959
960       See also asPalette().
961

const QPen QVariant::toPen () const

963       Returns the variant as a QPen if the variant has type() Pen; otherwise
964       returns an empty QPen.
965
966       See also asPen().
967

const QPixmap QVariant::toPixmap () const

969       Returns the variant as a QPixmap if the variant has type() Pixmap;
970       otherwise returns a null pixmap.
971
972       See also asPixmap().
973

const QPoint QVariant::toPoint () const

975       Returns the variant as a QPoint if the variant has type() Point;
976       otherwise returns a point (0, 0).
977
978       See also asPoint().
979

const QPointArray QVariant::toPointArray () const

981       Returns the variant as a QPointArray if the variant has type()
982       PointArray; otherwise returns an empty QPointArray.
983
984       See also asPointArray().
985

const QRect QVariant::toRect () const

987       Returns the variant as a QRect if the variant has type() Rect;
988       otherwise returns an empty rectangle.
989
990       See also asRect().
991

const QRegion QVariant::toRegion () const

993       Returns the variant as a QRegion if the variant has type() Region;
994       otherwise returns an empty QRegion.
995
996       See also asRegion().
997

const QSize QVariant::toSize () const

999       Returns the variant as a QSize if the variant has type() Size;
1000       otherwise returns an invalid size.
1001
1002       See also asSize().
1003

QSizePolicy QVariant::toSizePolicy () const

1005       Returns the variant as a QSizePolicy if the variant has type()
1006       SizePolicy; otherwise returns an undefined (but legal) size policy.
1007

const QString QVariant::toString () const

1009       Returns the variant as a QString if the variant can be cast to String,
1010       otherwise returns QString::null.
1011
1012       See also asString() and canCast().
1013

const QStringList QVariant::toStringList () const

1015       Returns the variant as a QStringList if the variant has type()
1016       StringList or List of a type that can be converted to QString;
1017       otherwise returns an empty list.
1018
1019       Note that if you want to iterate over the list, you should iterate over
1020       a copy, e.g.
1021
1022           QStringList list = myVariant.toStringList();
1023           QStringList::Iterator it = list.begin();
1024           while( it != list.end() ) {
1025               myProcessing( *it );
1026               ++it;
1027           }
1028
1029       See also asStringList().
1030

const QTime QVariant::toTime () const

1032       Returns the variant as a QTime if the variant can be cast to Time;
1033       otherwise returns an invalid date.
1034
1035       Note that if the type() is String, CString or ByteArray an invalid time
1036       will be returned if the string cannot be parsed as a Qt::ISODate format
1037       time.
1038
1039       See also asTime().
1040

uint QVariant::toUInt ( bool * ok = 0 ) const

1042       Returns the variant as an unsigned int if the variant can be cast to
1043       UInt; otherwise returns 0.
1044
1045       If ok is non-null: *ok is set to TRUE if the value could be converted
1046       to an unsigned int; otherwise *ok is set to FALSE.
1047
1048       See also asUInt() and canCast().
1049

Q_ULLONG QVariant::toULongLong ( bool * ok = 0 ) const

1051       Returns the variant as as an unsigned long long int if the variant can
1052       be cast to ULongLong; otherwise returns 0.
1053
1054       If ok is non-null: *ok is set to TRUE if the value could be converted
1055       to an int; otherwise *ok is set to FALSE.
1056
1057       See also asULongLong() and canCast().
1058

Type QVariant::type () const

1060       Returns the storage type of the value stored in the variant. Usually
1061       it's best to test with canCast() whether the variant can deliver the
1062       data type you are interested in.
1063

const char * QVariant::typeName () const

1065       Returns the name of the type stored in the variant. The returned
1066       strings describe the C++ datatype used to store the data: for example,
1067       "QFont", "QString", or "QValueList<QVariant>". An Invalid variant
1068       returns 0.
1069

const char * QVariant::typeToName ( Type typ ) [static]

1071       Converts the enum representation of the storage type, typ, to its
1072       string representation.
1073
1074

SEE ALSO

1076       http://doc.trolltech.com/qvariant.html
1077       http://www.trolltech.com/faq/tech.html
1078
1080       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
1081       license file included in the distribution for a complete license
1082       statement.
1083

AUTHOR

1085       Generated automatically from the source code.
1086

BUGS

1088       If you find a bug in Qt, please report it as described in
1089       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
1090       help you. Thank you.
1091
1092       The definitive Qt documentation is provided in HTML format; it is
1093       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
1094       web browser. This man page is provided as a convenience for those users
1095       who prefer man pages, although this format is not officially supported
1096       by Trolltech.
1097
1098       If you find errors in this manual page, please report them to qt-
1099       bugs@trolltech.com.  Please include the name of the manual page
1100       (qvariant.3qt) and the Qt version (3.3.8).
1101
1102
1103
1104Trolltech AS                    2 February 2007                  QVariant(3qt)
Impressum