Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The TQVariant class acts like a union for the most common TQt data types. More...
#include <ntqvariant.h>
Because C++ forbids unions from including types that have non-default constructors or destructors, most interesting TQt classes cannot be used in unions. Without TQVariant, this would be a problem for TQObject::property() and for database work, etc.
A TQVariant object holds a single value of a single type() at a time. (Some type()s are multi-valued, for example a string list.) You can find out what type, T, the variant holds, convert it to a different type using one of the asT() functions, e.g. asSize(), get its value using one of the toT() functions, e.g. toSize(), and check whether the type can be converted to a particular type using canCast().
The methods named toT() (for any supported T, see the Type documentation for a list) are const. If you ask for the stored type, they return a copy of the stored object. If you ask for a type that can be generated from the stored type, toT() copies and converts and leaves the object itself unchanged. If you ask for a type that cannot be generated from the stored type, the result depends on the type (see the function documentation for details).
Note that three data types supported by TQVariant are explicitly shared, namely TQImage, TQPointArray, and TQCString, and in these cases the toT() methods return a shallow copy. In almost all cases you must make a deep copy of the returned values before modifying them.
The asT() functions are not const. They do conversion like the toT() methods, set the variant to hold the converted value, and return a reference to the new contents of the variant.
Here is some example code to demonstrate the use of TQVariant:
TQDataStream out(...); TQVariant v(123); // The variant now contains an int int x = v.toInt(); // x = 123 out << v; // Writes a type tag and an int to out v = TQVariant("hello"); // The variant now contains a TQCString v = TQVariant(tr("hello"));// The variant now contains a TQString int y = v.toInt(); // y = 0 since v cannot be converted to an int TQString s = v.toString(); // s = tr("hello") (see TQObject::tr()) out << v; // Writes a type tag and a TQString to out ... TQDataStream in(...); // (opening the previously written stream) in >> v; // Reads an Int variant int z = v.toInt(); // z = 123 tqDebug("Type is %s", // prints "Type is int" v.typeName()); v.asInt() += 100; // The variant now hold the value 223. v = TQVariant( TQStringList() ); v.asStringList().append( "Hello" );
You can even store TQValueList TQVariant also supports the notion of NULL values, where you have a
defined type with no value set.
See the Collection Classes.
See also Miscellaneous Classes and Object Model.
This enum type defines the types of variable that a TQVariant can
contain.
Note that TQt's definition of bool depends on the compiler.
tqglobal.h has the system-dependent definition of bool.
If you want to modify the TQCString after you've passed it to this
constructor, we recommend passing a deep copy (see
TQCString::copy()).
If val is null, the resulting variant has type Invalid.
Because TQImage is explicitly shared, you may need to pass a deep copy to the variant using TQImage::copy(), e.g. if you intend
changing the image you've passed later on.
Because TQPointArray is explicitly shared, you may need to pass a
deep copy to the variant using TQPointArray::copy(), e.g. if you
intend changing the point array you've passed later on.
Note that subclasses that reimplement clear() should reimplement
the destructor to call clear(). This destructor calls clear(), but
because it is the destructor, TQVariant::clear() is called rather
than a subclass's clear().
Tries to convert the variant to hold a TQBitArray value. If that is
not possible then the variant is set to an empty bitarray.
Returns a reference to the stored bitarray.
See also toBitArray().
Tries to convert the variant to hold a bitmap value. If that is
not possible the variant is set to a null bitmap.
Returns a reference to the stored bitmap.
See also toBitmap().
Tries to convert the variant to hold a brush value. If that is not
possible the variant is set to a default black brush.
Returns a reference to the stored brush.
See also toBrush().
Tries to convert the variant to hold a TQByteArray value. If that
is not possible then the variant is set to an empty bytearray.
Returns a reference to the stored bytearray.
See also toByteArray().
Tries to convert the variant to hold a string value. If that is
not possible the variant is set to an empty string.
Returns a reference to the stored string.
See also toCString().
Tries to convert the variant to hold a TQColor value. If that is
not possible the variant is set to an invalid color.
Returns a reference to the stored color.
See also toColor() and TQColor::isValid().
Tries to convert the variant to hold a TQColorGroup value. If that
is not possible the variant is set to a color group of all black
colors.
Returns a reference to the stored color group.
See also toColorGroup().
Tries to convert the variant to hold a TQCursor value. If that is
not possible the variant is set to a default arrow cursor.
Returns a reference to the stored cursor.
See also toCursor().
Tries to convert the variant to hold a TQDate value. If that is not
possible then the variant is set to an invalid date.
Returns a reference to the stored date.
See also toDate().
Tries to convert the variant to hold a TQDateTime value. If that is
not possible then the variant is set to an invalid date/time.
Returns a reference to the stored date/time.
See also toDateTime().
Tries to convert the variant to hold a TQFont. If that is not
possible the variant is set to the application's default font.
Returns a reference to the stored font.
See also toFont().
Tries to convert the variant to hold a TQIconSet value. If that is
not possible the variant is set to an empty iconset.
Returns a reference to the stored iconset.
See also toIconSet().
Tries to convert the variant to hold an image value. If that is
not possible the variant is set to a null image.
Returns a reference to the stored image.
See also toImage().
Tries to convert the variant to hold a TQKeySequence value. If that
is not possible then the variant is set to an empty key sequence.
Returns a reference to the stored key sequence.
See also toKeySequence().
Note that if you want to iterate over the list, you should iterate
over a copy, e.g.
Note that if you want to iterate over the map, you should iterate
over a copy, e.g.
Tries to convert the variant to hold a TQPalette value. If that is
not possible the variant is set to a palette of black colors.
Returns a reference to the stored palette.
See also toString().
Tries to convert the variant to hold a TQPen value. If that
is not possible then the variant is set to an empty pen.
Returns a reference to the stored pen.
See also toPen().
Tries to convert the variant to hold a pixmap value. If that is
not possible the variant is set to a null pixmap.
Returns a reference to the stored pixmap.
See also toPixmap().
Tries to convert the variant to hold a point value. If that is not
possible the variant is set to a (0, 0) point.
Returns a reference to the stored point.
See also toPoint().
Tries to convert the variant to hold a TQPointArray value. If that
is not possible the variant is set to an empty point array.
Returns a reference to the stored point array.
See also toPointArray().
Tries to convert the variant to hold a rectangle value. If that is
not possible the variant is set to an empty rectangle.
Returns a reference to the stored rectangle.
See also toRect().
Tries to convert the variant to hold a TQRegion value. If that is
not possible the variant is set to a null region.
Returns a reference to the stored region.
See also toRegion().
Tries to convert the variant to hold a TQSize value. If that is not
possible the variant is set to an invalid size.
Returns a reference to the stored size.
See also toSize() and TQSize::isValid().
Tries to convert the variant to hold a TQSizePolicy value. If that
fails, the variant is set to an arbitrary (valid) size policy.
Tries to convert the variant to hold a string value. If that is
not possible the variant is set to an empty string.
Returns a reference to the stored string.
See also toString().
Tries to convert the variant to hold a TQStringList value. If that
is not possible the variant is set to an empty string list.
Returns a reference to the stored string list.
Note that if you want to iterate over the list, you should
iterate over a copy, e.g.
See also toStringList().
Tries to convert the variant to hold a TQTime value. If that is not
possible then the variant is set to an invalid time.
Returns a reference to the stored time.
See also toTime().
The following casts are done automatically:
See also canCast().
Returns TRUE if the storage type of this variant is not
TQVariant::Invalid; otherwise returns FALSE.
Returns an iterator to the first item in the list if the variant's
type is appropriate; otherwise returns a null iterator.
Returns the end iterator for the list if the variant's type is
appropriate; otherwise returns a null iterator.
Returns an iterator to the first item in the map, if the variant's
type is appropriate; otherwise returns a null iterator.
Returns the end iterator for the map, if the variant's type is
appropriate; otherwise returns a null iterator.
Returns an iterator to the item in the map with key as key, if
the variant's type is appropriate and key is a valid key;
otherwise returns a null iterator.
If the string representation cannot be converted to any enum
representation, the variant is set to Invalid.
This is a deep copy of the variant, but note that if the variant
holds an explicitly shared type such as TQImage, a shallow copy is
performed.
Returns an iterator to the first string in the list if the
variant's type is StringList; otherwise returns a null iterator.
Returns the end iterator for the list if the variant's type is
StringList; otherwise returns a null iterator.
See also asBitArray().
See also asBitmap().
Returns TRUE if the variant has a numeric type and its value is
non-zero, or if the variant has type String, ByteArray or CString
and its lower-case content is not empty, "0" or "false"; otherwise
returns FALSE.
See also asBool() and canCast().
See also asBrush().
See also asByteArray() and canCast().
See also asCString() and canCast().
See also asColor() and canCast().
See also asColorGroup().
See also asCursor().
Note that if the type() is String, CString or ByteArray an invalid
date will be returned if the string cannot be parsed as a
TQt::ISODate format date.
See also asDate() and canCast().
Note that if the type() is String, CString or ByteArray an invalid
TQDateTime will be returned if the string cannot be parsed as a
TQt::ISODate format date/time.
See also asDateTime().
If ok is non-null: *ok is set to TRUE if the value could be
converted to a double; otherwise *ok is set to FALSE.
See also asDouble() and canCast().
See also asFont() and canCast().
See also asIconSet().
See also asImage().
If ok is non-null: *ok is set to TRUE if the value could be
converted to an int; otherwise *ok is set to FALSE.
See also asInt() and canCast().
See also asKeySequence() and canCast().
Note that if you want to iterate over the list, you should iterate
over a copy, e.g.
See also asList().
If ok is non-null: *ok is set to TRUE if the value could be
converted to an int; otherwise *ok is set to FALSE.
See also asLongLong() and canCast().
Note that if you want to iterate over the map, you should iterate
over a copy, e.g.
See also asMap().
See also asPalette().
See also asPen().
See also asPixmap().
See also asPoint().
See also asPointArray().
See also asRect().
See also asRegion().
See also asSize().
See also asString() and canCast().
Note that if you want to iterate over the list, you should iterate
over a copy, e.g.
See also asStringList().
Note that if the type() is String, CString or ByteArray an invalid
time will be returned if the string cannot be parsed as a
TQt::ISODate format time.
See also asTime().
If ok is non-null: *ok is set to TRUE if the value could be
converted to an unsigned int; otherwise *ok is set to FALSE.
See also asUInt() and canCast().
If ok is non-null: *ok is set to TRUE if the value could be
converted to an int; otherwise *ok is set to FALSE.
See also asULongLong() and canCast().
Returns the storage type of the value stored in the variant.
Usually it's best to test with canCast() whether the variant can
deliver the data type you are interested in.
This file is part of the TQt toolkit.
Copyright © 1995-2007
Trolltech. All Rights Reserved.
TQVariant x, y( TQString() ), z( TQString("") );
x.asInt();
// x.isNull() == TRUE, y.isNull() == TRUE, z.isNull() == FALSE
Member Type Documentation
TQVariant::Type
Member Function Documentation
TQVariant::TQVariant ()
Constructs an invalid variant.
TQVariant::TQVariant ( bool val, int )
Constructs a new variant with a boolean value, val. The integer
argument is a dummy, necessary for compatibility with some
compilers.
TQVariant::TQVariant ( double val )
Constructs a new variant with a floating point value, val.
TQVariant::TQVariant ( TQSizePolicy val )
Constructs a new variant with a size policy value, val.
TQVariant::TQVariant ( const TQVariant & p )
Constructs a copy of the variant, p, passed as the argument to
this constructor. Usually this is a deep copy, but a shallow copy
is made if the stored data type is explicitly shared, as e.g.
TQImage is.
TQVariant::TQVariant ( TQDataStream & s )
Reads the variant from the data stream, s.
TQVariant::TQVariant ( const TQString & val )
Constructs a new variant with a string value, val.
TQVariant::TQVariant ( const TQCString & val )
Constructs a new variant with a C-string value, val.
TQVariant::TQVariant ( const char * val )
Constructs a new variant with a C-string value of val if val
is non-null. The variant creates a deep copy of val.
TQVariant::TQVariant ( const TQStringList & val )
Constructs a new variant with a string list value, val.
TQVariant::TQVariant ( const TQFont & val )
Constructs a new variant with a font value, val.
TQVariant::TQVariant ( const TQPixmap & val )
Constructs a new variant with a pixmap value, val.
TQVariant::TQVariant ( const TQImage & val )
Constructs a new variant with an image value, val.
TQVariant::TQVariant ( const TQBrush & val )
Constructs a new variant with a brush value, val.
TQVariant::TQVariant ( const TQPoint & val )
Constructs a new variant with a point value, val.
TQVariant::TQVariant ( const TQRect & val )
Constructs a new variant with a rect value, val.
TQVariant::TQVariant ( const TQSize & val )
Constructs a new variant with a size value, val.
TQVariant::TQVariant ( const TQColor & val )
Constructs a new variant with a color value, val.
TQVariant::TQVariant ( const TQPalette & val )
Constructs a new variant with a color palette value, val.
TQVariant::TQVariant ( const TQColorGroup & val )
Constructs a new variant with a color group value, val.
TQVariant::TQVariant ( const TQIconSet & val )
Constructs a new variant with an icon set value, val.
TQVariant::TQVariant ( const TQPointArray & val )
Constructs a new variant with a point array value, val.
TQVariant::TQVariant ( const TQRegion & val )
Constructs a new variant with a region value, val.
TQVariant::TQVariant ( const TQBitmap & val )
Constructs a new variant with a bitmap value, val.
TQVariant::TQVariant ( const TQCursor & val )
Constructs a new variant with a cursor value, val.
TQVariant::TQVariant ( const TQDate & val )
Constructs a new variant with a date value, val.
TQVariant::TQVariant ( const TQTime & val )
Constructs a new variant with a time value, val.
TQVariant::TQVariant ( const TQDateTime & val )
Constructs a new variant with a date/time value, val.
TQVariant::TQVariant ( const TQByteArray & val )
Constructs a new variant with a bytearray value, val.
TQVariant::TQVariant ( const TQBitArray & val )
Constructs a new variant with a bitarray value, val.
TQVariant::TQVariant ( const TQKeySequence & val )
Constructs a new variant with a key sequence value, val.
TQVariant::TQVariant ( const TQPen & val )
Constructs a new variant with a pen value, val.
TQVariant::TQVariant ( const TQValueList<TQVariant> & val )
Constructs a new variant with a list value, val.
TQVariant::TQVariant ( const TQMap<TQString, TQVariant> & val )
Constructs a new variant with a map of TQVariants, val.
TQVariant::TQVariant ( int val )
Constructs a new variant with an integer value, val.
TQVariant::TQVariant ( uint val )
Constructs a new variant with an unsigned integer value, val.
TQVariant::TQVariant ( TQ_LLONG val )
Constructs a new variant with a long long integer value, val.
TQVariant::TQVariant ( TQ_ULLONG val )
Constructs a new variant with an unsigned long long integer value, val.
TQVariant::~TQVariant ()
Destroys the TQVariant and the contained object.
TQBitArray & TQVariant::asBitArray ()
TQBitmap & TQVariant::asBitmap ()
bool & TQVariant::asBool ()
Returns the variant's value as bool reference.
TQBrush & TQVariant::asBrush ()
TQByteArray & TQVariant::asByteArray ()
TQCString & TQVariant::asCString ()
TQColor & TQVariant::asColor ()
TQColorGroup & TQVariant::asColorGroup ()
TQCursor & TQVariant::asCursor ()
TQDate & TQVariant::asDate ()
TQDateTime & TQVariant::asDateTime ()
double & TQVariant::asDouble ()
Returns the variant's value as double reference.
TQFont & TQVariant::asFont ()
TQIconSet & TQVariant::asIconSet ()
TQImage & TQVariant::asImage ()
int & TQVariant::asInt ()
Returns the variant's value as int reference.
TQKeySequence & TQVariant::asKeySequence ()
TQValueList<TQVariant> & TQVariant::asList ()
Returns the variant's value as variant list reference.
TQValueList<TQVariant> list = myVariant.asList();
TQValueList<TQVariant>::Iterator it = list.begin();
while( it != list.end() ) {
myProcessing( *it );
++it;
}
TQ_LLONG & TQVariant::asLongLong ()
Returns the variant's value as long long reference.
TQMap<TQString, TQVariant> & TQVariant::asMap ()
Returns the variant's value as variant map reference.
TQMap<TQString, TQVariant> map = myVariant.asMap();
TQMap<TQString, TQVariant>::Iterator it = map.begin();
while( it != map.end() ) {
myProcessing( *it );
++it;
}
TQPalette & TQVariant::asPalette ()
TQPen & TQVariant::asPen ()
TQPixmap & TQVariant::asPixmap ()
TQPoint & TQVariant::asPoint ()
TQPointArray & TQVariant::asPointArray ()
TQRect & TQVariant::asRect ()
TQRegion & TQVariant::asRegion ()
TQSize & TQVariant::asSize ()
TQSizePolicy & TQVariant::asSizePolicy ()
TQString & TQVariant::asString ()
TQStringList & TQVariant::asStringList ()
TQStringList list = myVariant.asStringList();
TQStringList::Iterator it = list.begin();
while( it != list.end() ) {
myProcessing( *it );
++it;
}
TQTime & TQVariant::asTime ()
uint & TQVariant::asUInt ()
Returns the variant's value as unsigned int reference.
TQ_ULLONG & TQVariant::asULongLong ()
Returns the variant's value as unsigned long long reference.
bool TQVariant::canCast ( Type t ) const
Returns TRUE if the variant's type can be cast to the requested
type, t. Such casting is done automatically when calling the
toInt(), toBool(), ... or asInt(), asBool(), ... methods.
Type Automatically Cast To
Bool Double, Int, UInt, LongLong, ULongLong, String, CString, ByteArray
Color String. CString. ByteArray
Date String, CString, ByteArray, DateTime
DateTime String, CString, ByteArray, Date, Time
Double String, CString, ByteArray, Int, Bool, UInt, LongLong, ULongLong
Font String, CString, ByteArray
Int String, CString, ByteArray, Double, Bool, UInt, LongLong, ULongLong, KeySequence
LongLong String, CString, ByteArray, Double, Bool, UInt, LongLong, ULongLong, KeySequence
ULongLong String, CString, ByteArray, Double, Bool, UInt, LongLong, ULongLong, KeySequence
List StringList (if the list contains only strings or
something that can be cast to a string)
String CString, ByteArray, CString, Int, UInt, Bool, Double, Date,
Time, DateTime, KeySequence, Font, Color
CString String, ByteArray, Int, UInt, Bool, Double, Date, ULongLong, LongLong
ByteArray String, CString, Int, UInt, Bool, Double, Date, ULongLong, LongLong
StringList List
Time String
Int String, CString, ByteArray, Double, Bool, UInt, LongLong, ULongLong, KeySequence
KeySequence String, CString, ByteArray, Int, UInt, LongLong, ULongLong
bool TQVariant::cast ( Type t )
Casts the variant to the requested type. If the cast cannot be
done, the variant is set to the default value of the requested
type (e.g. an empty string if the requested type t is
TQVariant::String, an empty point array if the requested type t
is TQVariant::PointArray, etc). Returns TRUE if the current type of
the variant was successfully cast; otherwise returns FALSE.
void TQVariant::clear ()
Convert this variant to type Invalid and free up any resources
used.
bool TQVariant::isNull () const
Returns TRUE if this is a NULL variant, FALSE otherwise.
bool TQVariant::isValid () const
TQValueListConstIterator<TQVariant> TQVariant::listBegin () const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
TQValueListConstIterator<TQVariant> TQVariant::listEnd () const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
TQMapConstIterator<TQString, TQVariant> TQVariant::mapBegin () const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
TQMapConstIterator<TQString, TQVariant> TQVariant::mapEnd () const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
TQMapConstIterator<TQString, TQVariant> TQVariant::mapFind ( const TQString & key ) const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
Type TQVariant::nameToType ( const char * name ) [static]
Converts the string representation of the storage type given in name, to its enum representation.
bool TQVariant::operator!= ( const TQVariant & v ) const
Compares this TQVariant with v and returns TRUE if they are not
equal; otherwise returns FALSE.
TQVariant & TQVariant::operator= ( const TQVariant & variant )
Assigns the value of the variant variant to this variant.
bool TQVariant::operator== ( const TQVariant & v ) const
Compares this TQVariant with v and returns TRUE if they are
equal; otherwise returns FALSE.
TQValueListConstIterator<TQString> TQVariant::stringListBegin () const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
TQValueListConstIterator<TQString> TQVariant::stringListEnd () const
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
const TQBitArray TQVariant::toBitArray () const
Returns the variant as a TQBitArray if the variant has type()
BitArray; otherwise returns an empty bitarray.
const TQBitmap TQVariant::toBitmap () const
Returns the variant as a TQBitmap if the variant has type() Bitmap;
otherwise returns a null TQBitmap.
bool TQVariant::toBool () const
Returns the variant as a bool if the variant can be cast to Bool;
otherWise returns FALSE.
const TQBrush TQVariant::toBrush () const
Returns the variant as a TQBrush if the variant has type() Brush;
otherwise returns a default brush (with all black colors).
const TQByteArray TQVariant::toByteArray () const
Returns the variant as a TQByteArray if the variant can be cast to
a ByteArray; otherwise returns an empty bytearray.
const TQCString TQVariant::toCString () const
Returns the variant as a TQCString if the variant can be cast to a
CString; otherwise returns 0.
const TQColor TQVariant::toColor () const
Returns the variant as a TQColor if the variant can be cast to Color;
otherwise returns an invalid color.
const TQColorGroup TQVariant::toColorGroup () const
Returns the variant as a TQColorGroup if the variant has type()
ColorGroup; otherwise returns a completely black color group.
const TQCursor TQVariant::toCursor () const
Returns the variant as a TQCursor if the variant has type() Cursor;
otherwise returns the default arrow cursor.
const TQDate TQVariant::toDate () const
Returns the variant as a TQDate if the variant can be cast to Date;
otherwise returns an invalid date.
const TQDateTime TQVariant::toDateTime () const
Returns the variant as a TQDateTime if the variant can be cast to
DateTime; otherwise returns an invalid TQDateTime.
double TQVariant::toDouble ( bool * ok = 0 ) const
Returns the variant as a double if the variant can be cast to
Double; otherwise returns 0.0.
const TQFont TQVariant::toFont () const
Returns the variant as a TQFont if the variant can be cast to Font;
otherwise returns the application's default font.
const TQIconSet TQVariant::toIconSet () const
Returns the variant as a TQIconSet if the variant has type()
IconSet; otherwise returns an icon set of null pixmaps.
const TQImage TQVariant::toImage () const
Returns the variant as a TQImage if the variant has type() Image;
otherwise returns a null image.
int TQVariant::toInt ( bool * ok = 0 ) const
Returns the variant as an int if the variant can be cast to Int;
otherwise returns 0.
const TQKeySequence TQVariant::toKeySequence () const
Returns the variant as a TQKeySequence if the variant can be cast
to a KeySequence; otherwise returns an empty key sequence.
const TQValueList<TQVariant> TQVariant::toList () const
Returns the variant as a TQValueList
TQValueList<TQVariant> list = myVariant.toList();
TQValueList<TQVariant>::Iterator it = list.begin();
while( it != list.end() ) {
myProcessing( *it );
++it;
}
TQ_LLONG TQVariant::toLongLong ( bool * ok = 0 ) const
Returns the variant as a long long int if the variant can be cast
to LongLong; otherwise returns 0.
const TQMap<TQString, TQVariant> TQVariant::toMap () const
Returns the variant as a TQMap
TQMap<TQString, TQVariant> map = myVariant.toMap();
TQMap<TQString, TQVariant>::Iterator it = map.begin();
while( it != map.end() ) {
myProcessing( *it );
++it;
}
const TQPalette TQVariant::toPalette () const
Returns the variant as a TQPalette if the variant has type()
Palette; otherwise returns a completely black palette.
const TQPen TQVariant::toPen () const
Returns the variant as a TQPen if the variant has type()
Pen; otherwise returns an empty TQPen.
const TQPixmap TQVariant::toPixmap () const
Returns the variant as a TQPixmap if the variant has type() Pixmap;
otherwise returns a null pixmap.
const TQPoint TQVariant::toPoint () const
Returns the variant as a TQPoint if the variant has type() Point;
otherwise returns a point (0, 0).
const TQPointArray TQVariant::toPointArray () const
Returns the variant as a TQPointArray if the variant has type()
PointArray; otherwise returns an empty TQPointArray.
const TQRect TQVariant::toRect () const
Returns the variant as a TQRect if the variant has type() Rect;
otherwise returns an empty rectangle.
const TQRegion TQVariant::toRegion () const
Returns the variant as a TQRegion if the variant has type() Region;
otherwise returns an empty TQRegion.
const TQSize TQVariant::toSize () const
Returns the variant as a TQSize if the variant has type() Size;
otherwise returns an invalid size.
TQSizePolicy TQVariant::toSizePolicy () const
Returns the variant as a TQSizePolicy if the variant has type()
SizePolicy; otherwise returns an undefined (but legal) size
policy.
const TQString TQVariant::toString () const
Returns the variant as a TQString if the variant can be cast to
String, otherwise returns TQString::null.
const TQStringList TQVariant::toStringList () const
Returns the variant as a TQStringList if the variant has type()
StringList or List of a type that can be converted to TQString;
otherwise returns an empty list.
TQStringList list = myVariant.toStringList();
TQStringList::Iterator it = list.begin();
while( it != list.end() ) {
myProcessing( *it );
++it;
}
const TQTime TQVariant::toTime () const
Returns the variant as a TQTime if the variant can be cast to Time;
otherwise returns an invalid date.
uint TQVariant::toUInt ( bool * ok = 0 ) const
Returns the variant as an unsigned int if the variant can be cast
to UInt; otherwise returns 0.
TQ_ULLONG TQVariant::toULongLong ( bool * ok = 0 ) const
Returns the variant as as an unsigned long long int if the variant
can be cast to ULongLong; otherwise returns 0.
Type TQVariant::type () const
const char * TQVariant::typeName () const
Returns the name of the type stored in the variant. The returned
strings describe the C++ datatype used to store the data: for
example, "TQFont", "TQString", or "TQValueListconst char * TQVariant::typeToName ( Type typ ) [static]
Converts the enum representation of the storage type, typ, to
its string representation.
Copyright © 2007
Trolltech Trademarks