Eneboo - Documentación para desarrolladores
Clases | Tipos públicos | Métodos públicos | Métodos públicos estáticos
Referencia de la Clase QVariant

The QVariant class acts like a union for the most common Qt data types. Más...

#include <qvariant.h>

Lista de todos los miembros.

Clases

class  Private

Tipos públicos

enum  Type {
  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, 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
}
enum  Type {
  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, 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
}

Métodos públicos

 QVariant ()
 ~QVariant ()
 QVariant (const QVariant &)
 QVariant (QDataStream &s)
 QVariant (const QString &)
 QVariant (const QCString &)
 QVariant (const char *)
 QVariant (const QStringList &)
 QVariant (const QFont &)
 QVariant (const QPixmap &)
 QVariant (const QImage &)
 QVariant (const QBrush &)
 QVariant (const QPoint &)
 QVariant (const QRect &)
 QVariant (const QSize &)
 QVariant (const QColor &)
 QVariant (const QPalette &)
 QVariant (const QColorGroup &)
 QVariant (const QIconSet &)
 QVariant (const QPointArray &)
 QVariant (const QRegion &)
 QVariant (const QBitmap &)
 QVariant (const QCursor &)
 QVariant (const QDate &)
 QVariant (const QTime &)
 QVariant (const QDateTime &)
 QVariant (const QByteArray &)
 QVariant (const QBitArray &)
 QVariant (const QKeySequence &)
 QVariant (const QPen &)
 QVariant (const QValueList< QVariant > &)
 QVariant (const QMap< QString, QVariant > &)
 QVariant (int)
 QVariant (uint)
 QVariant (Q_LLONG)
 QVariant (Q_ULLONG)
 QVariant (bool, int)
 QVariant (double)
 QVariant (QSizePolicy)
QVariantoperator= (const QVariant &)
bool operator== (const QVariant &) const
bool operator!= (const QVariant &) const
Type type () const
const char * typeName () const
bool canCast (Type) const
bool cast (Type)
bool isValid () const
bool isNull () const
void clear ()
const QString toString () const
const QCString toCString () const
const QStringList toStringList () const
const QFont toFont () const
const QPixmap toPixmap () const
const QImage toImage () const
const QBrush toBrush () const
const QPoint toPoint () const
const QRect toRect () const
const QSize toSize () const
const QColor toColor () const
const QPalette toPalette () const
const QColorGroup toColorGroup () const
const QIconSet toIconSet () const
const QPointArray toPointArray () const
const QBitmap toBitmap () const
const QRegion toRegion () const
const QCursor toCursor () const
const QDate toDate () const
const QTime toTime () const
const QDateTime toDateTime () const
const QByteArray toByteArray () const
const QBitArray toBitArray () const
const QKeySequence toKeySequence () const
const QPen toPen () const
int toInt (bool *ok=0) const
uint toUInt (bool *ok=0) const
Q_LLONG toLongLong (bool *ok=0) const
Q_ULLONG toULongLong (bool *ok=0) const
bool toBool () const
double toDouble (bool *ok=0) const
const QValueList< QVarianttoList () const
const QMap< QString, QVarianttoMap () const
QSizePolicy toSizePolicy () const
QValueListConstIterator< QStringstringListBegin () const
QValueListConstIterator< QStringstringListEnd () const
QValueListConstIterator< QVariantlistBegin () const
QValueListConstIterator< QVariantlistEnd () const
QMapConstIterator< QString,
QVariant
mapBegin () const
QMapConstIterator< QString,
QVariant
mapEnd () const
QMapConstIterator< QString,
QVariant
mapFind (const QString &) const
QStringasString ()
QCStringasCString ()
QStringListasStringList ()
QFontasFont ()
QPixmapasPixmap ()
QImageasImage ()
QBrushasBrush ()
QPointasPoint ()
QRectasRect ()
QSizeasSize ()
QColorasColor ()
QPaletteasPalette ()
QColorGroupasColorGroup ()
QIconSetasIconSet ()
QPointArrayasPointArray ()
QBitmapasBitmap ()
QRegionasRegion ()
QCursorasCursor ()
QDateasDate ()
QTimeasTime ()
QDateTimeasDateTime ()
QByteArrayasByteArray ()
QBitArrayasBitArray ()
QKeySequenceasKeySequence ()
QPenasPen ()
intasInt ()
uintasUInt ()
Q_LLONG & asLongLong ()
Q_ULLONG & asULongLong ()
boolasBool ()
double & asDouble ()
QValueList< QVariant > & asList ()
QMap< QString, QVariant > & asMap ()
QSizePolicyasSizePolicy ()
void load (QDataStream &)
void save (QDataStream &) const
void * rawAccess (void *ptr=0, Type typ=Invalid, bool deepCopy=FALSE)
 QVariant ()
 ~QVariant ()
 QVariant (const QVariant &)
 QVariant (QDataStream &s)
 QVariant (const QString &)
 QVariant (const QCString &)
 QVariant (const char *)
 QVariant (const QStringList &)
 QVariant (const QFont &)
 QVariant (const QPixmap &)
 QVariant (const QImage &)
 QVariant (const QBrush &)
 QVariant (const QPoint &)
 QVariant (const QRect &)
 QVariant (const QSize &)
 QVariant (const QColor &)
 QVariant (const QPalette &)
 QVariant (const QColorGroup &)
 QVariant (const QIconSet &)
 QVariant (const QPointArray &)
 QVariant (const QRegion &)
 QVariant (const QBitmap &)
 QVariant (const QCursor &)
 QVariant (const QDate &)
 QVariant (const QTime &)
 QVariant (const QDateTime &)
 QVariant (const QByteArray &)
 QVariant (const QBitArray &)
 QVariant (const QKeySequence &)
 QVariant (const QPen &)
 QVariant (const QValueList< QVariant > &)
 QVariant (const QMap< QString, QVariant > &)
 QVariant (int)
 QVariant (uint)
 QVariant (Q_LLONG)
 QVariant (Q_ULLONG)
 QVariant (bool, int)
 QVariant (double)
 QVariant (QSizePolicy)
QVariantoperator= (const QVariant &)
bool operator== (const QVariant &) const
bool operator!= (const QVariant &) const
Type type () const
const char * typeName () const
bool canCast (Type) const
bool cast (Type)
bool isValid () const
bool isNull () const
void clear ()
const QString toString () const
const QCString toCString () const
const QStringList toStringList () const
const QFont toFont () const
const QPixmap toPixmap () const
const QImage toImage () const
const QBrush toBrush () const
const QPoint toPoint () const
const QRect toRect () const
const QSize toSize () const
const QColor toColor () const
const QPalette toPalette () const
const QColorGroup toColorGroup () const
const QIconSet toIconSet () const
const QPointArray toPointArray () const
const QBitmap toBitmap () const
const QRegion toRegion () const
const QCursor toCursor () const
const QDate toDate () const
const QTime toTime () const
const QDateTime toDateTime () const
const QByteArray toByteArray () const
const QBitArray toBitArray () const
const QKeySequence toKeySequence () const
const QPen toPen () const
int toInt (bool *ok=0) const
uint toUInt (bool *ok=0) const
Q_LLONG toLongLong (bool *ok=0) const
Q_ULLONG toULongLong (bool *ok=0) const
bool toBool () const
double toDouble (bool *ok=0) const
const QValueList< QVarianttoList () const
const QMap< QString, QVarianttoMap () const
QSizePolicy toSizePolicy () const
QValueListConstIterator< QStringstringListBegin () const
QValueListConstIterator< QStringstringListEnd () const
QValueListConstIterator< QVariantlistBegin () const
QValueListConstIterator< QVariantlistEnd () const
QMapConstIterator< QString,
QVariant
mapBegin () const
QMapConstIterator< QString,
QVariant
mapEnd () const
QMapConstIterator< QString,
QVariant
mapFind (const QString &) const
QStringasString ()
QCStringasCString ()
QStringListasStringList ()
QFontasFont ()
QPixmapasPixmap ()
QImageasImage ()
QBrushasBrush ()
QPointasPoint ()
QRectasRect ()
QSizeasSize ()
QColorasColor ()
QPaletteasPalette ()
QColorGroupasColorGroup ()
QIconSetasIconSet ()
QPointArrayasPointArray ()
QBitmapasBitmap ()
QRegionasRegion ()
QCursorasCursor ()
QDateasDate ()
QTimeasTime ()
QDateTimeasDateTime ()
QByteArrayasByteArray ()
QBitArrayasBitArray ()
QKeySequenceasKeySequence ()
QPenasPen ()
intasInt ()
uintasUInt ()
Q_LLONG & asLongLong ()
Q_ULLONG & asULongLong ()
boolasBool ()
double & asDouble ()
QValueList< QVariant > & asList ()
QMap< QString, QVariant > & asMap ()
QSizePolicyasSizePolicy ()
void load (QDataStream &)
void save (QDataStream &) const
void * rawAccess (void *ptr=0, Type typ=Invalid, bool deepCopy=FALSE)

Métodos públicos estáticos

static const char * typeToName (Type typ)
static Type nameToType (const char *name)
static const char * typeToName (Type typ)
static Type nameToType (const char *name)

Descripción detallada

The QVariant class acts like a union for the most common Qt data types.

Because C++ forbids unions from including types that have non-default constructors or destructors, most interesting Qt classes cannot be used in unions. Without QVariant, this would be a problem for QObject::property() and for database work, etc.

A QVariant 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 QVariant are explicitly shared, namely QImage, QPointArray, and QCString, 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 QVariant:

    QDataStream out(...);
    QVariant 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 = QVariant("hello");    // The variant now contains a QCString
    v = QVariant(tr("hello"));// The variant now contains a QString
    int y = v.toInt();        // y = 0 since v cannot be converted to an int
    QString s = v.toString(); // s = tr("hello")  (see QObject::tr())
    out << v;                 // Writes a type tag and a QString to out
    ...
    QDataStream in(...);      // (opening the previously written stream)
    in >> v;                  // Reads an Int variant
    int z = v.toInt();        // z = 123
    qDebug("Type is %s",      // prints "Type is int"
            v.typeName());
    v.asInt() += 100;         // The variant now hold the value 223.
    v = QVariant( QStringList() );
    v.asStringList().append( "Hello" );

You can even store QValueList<QVariant>s and QMap<QString,QVariant>s in a variant, so you can easily construct arbitrarily complex data structures of arbitrary types. This is very powerful and versatile, but may prove less memory and speed efficient than storing specific types in standard data structures.

QVariant also supports the notion of NULL values, where you have a defined type with no value set.

    QVariant x, y( QString() ), z( QString("") );
    x.asInt();
    // x.isNull() == TRUE, y.isNull() == TRUE, z.isNull() == FALSE

See the Collection Classes.


Documentación de las enumeraciones miembro de la clase

This enum type defines the types of variable that a QVariant can contain.

Invalid no type BitArray a QBitArray ByteArray a QByteArray Bitmap a QBitmap Bool a bool Brush a QBrush Color a QColor ColorGroup a QColorGroup Cursor a QCursor Date a QDate DateTime a QDateTime Double a double Font a QFont IconSet a QIconSet Image a QImage Int an int KeySequence a QKeySequence List a QValueList<QVariant> LongLong a long long ULongLong an unsigned long long Map a QMap<QString,QVariant> Palette a QPalette Pen a QPen Pixmap a QPixmap Point a QPoint PointArray a QPointArray Rect a QRect Region a QRegion Size a QSize SizePolicy a QSizePolicy String a QString CString a QCString StringList a QStringList Time a QTime UInt an unsigned int

Note that Qt's definition of bool depends on the compiler. qglobal.h has the system-dependent definition of bool.

Valores de enumeraciones:
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 
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 
Valores de enumeraciones:
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 
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 

Documentación del constructor y destructor

QVariant::QVariant ( )

Constructs an invalid variant.

QVariant::~QVariant ( )

Destroys the QVariant and the contained object.

Note that subclasses that reimplement clear() should reimplement the destructor to call clear(). This destructor calls clear(), but because it is the destructor, QVariant::clear() is called rather than a subclass's clear().

QVariant::QVariant ( const QVariant 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. QImage is.

QVariant::QVariant ( QDataStream s)

Reads the variant from the data stream, s.

QVariant::QVariant ( const QString val)

Constructs a new variant with a string value, val.

QVariant::QVariant ( const QCString val)

Constructs a new variant with a C-string value, val.

If you want to modify the QCString after you've passed it to this constructor, we recommend passing a deep copy (see QCString::copy()).

QVariant::QVariant ( 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.

If val is null, the resulting variant has type Invalid.

QVariant::QVariant ( const QStringList val)

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

QVariant::QVariant ( const QFont val)

Constructs a new variant with a font value, val.

QVariant::QVariant ( const QPixmap val)

Constructs a new variant with a pixmap value, val.

QVariant::QVariant ( const QImage val)

Constructs a new variant with an image value, val.

Because QImage is explicitly shared, you may need to pass a deep copy to the variant using QImage::copy(), e.g. if you intend changing the image you've passed later on.

QVariant::QVariant ( const QBrush val)

Constructs a new variant with a brush value, val.

QVariant::QVariant ( const QPoint val)

Constructs a new variant with a point value, val.

QVariant::QVariant ( const QRect val)

Constructs a new variant with a rect value, val.

QVariant::QVariant ( const QSize val)

Constructs a new variant with a size value, val.

QVariant::QVariant ( const QColor val)

Constructs a new variant with a color value, val.

QVariant::QVariant ( const QPalette val)

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

QVariant::QVariant ( const QColorGroup val)

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

QVariant::QVariant ( const QIconSet val)

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

QVariant::QVariant ( const QPointArray val)

Constructs a new variant with a point array value, val.

Because QPointArray is explicitly shared, you may need to pass a deep copy to the variant using QPointArray::copy(), e.g. if you intend changing the point array you've passed later on.

QVariant::QVariant ( const QRegion val)

Constructs a new variant with a region value, val.

QVariant::QVariant ( const QBitmap val)

Constructs a new variant with a bitmap value, val.

QVariant::QVariant ( const QCursor val)

Constructs a new variant with a cursor value, val.

QVariant::QVariant ( const QDate val)

Constructs a new variant with a date value, val.

QVariant::QVariant ( const QTime val)

Constructs a new variant with a time value, val.

QVariant::QVariant ( const QDateTime val)

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

QVariant::QVariant ( const QByteArray val)

Constructs a new variant with a bytearray value, val.

QVariant::QVariant ( const QBitArray val)

Constructs a new variant with a bitarray value, val.

QVariant::QVariant ( const QKeySequence val)

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

QVariant::QVariant ( const QPen val)

Constructs a new variant with a pen value, val.

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

Constructs a new variant with a list value, val.

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

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

QVariant::QVariant ( int  val)

Constructs a new variant with an integer value, val.

QVariant::QVariant ( uint  val)

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

QVariant::QVariant ( Q_LLONG  val)

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

QVariant::QVariant ( Q_ULLONG  val)

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

QVariant::QVariant ( bool  val,
int   
)

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

QVariant::QVariant ( double  val)

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

QVariant::QVariant ( QSizePolicy  val)

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

QVariant::QVariant ( )
QVariant::~QVariant ( )
QVariant::QVariant ( const QVariant )
QVariant::QVariant ( QDataStream s)
QVariant::QVariant ( const QString )
QVariant::QVariant ( const QCString )
QVariant::QVariant ( const char *  )
QVariant::QVariant ( const QStringList )
QVariant::QVariant ( const QFont )
QVariant::QVariant ( const QPixmap )
QVariant::QVariant ( const QImage )
QVariant::QVariant ( const QBrush )
QVariant::QVariant ( const QPoint )
QVariant::QVariant ( const QRect )
QVariant::QVariant ( const QSize )
QVariant::QVariant ( const QColor )
QVariant::QVariant ( const QPalette )
QVariant::QVariant ( const QColorGroup )
QVariant::QVariant ( const QIconSet )
QVariant::QVariant ( const QPointArray )
QVariant::QVariant ( const QRegion )
QVariant::QVariant ( const QBitmap )
QVariant::QVariant ( const QCursor )
QVariant::QVariant ( const QDate )
QVariant::QVariant ( const QTime )
QVariant::QVariant ( const QDateTime )
QVariant::QVariant ( const QByteArray )
QVariant::QVariant ( const QBitArray )
QVariant::QVariant ( const QKeySequence )
QVariant::QVariant ( const QPen )
QVariant::QVariant ( const QValueList< QVariant > &  )
QVariant::QVariant ( const QMap< QString, QVariant > &  )
QVariant::QVariant ( int  )
QVariant::QVariant ( uint  )
QVariant::QVariant ( Q_LLONG  )
QVariant::QVariant ( Q_ULLONG  )
QVariant::QVariant ( bool  ,
int   
)
QVariant::QVariant ( double  )
QVariant::QVariant ( QSizePolicy  )

Documentación de las funciones miembro

QBitArray & QVariant::asBitArray ( )

Tries to convert the variant to hold a QBitArray value. If that is not possible then the variant is set to an empty bitarray.

Returns a reference to the stored bitarray.

Ver también:
toBitArray()
QBitArray& QVariant::asBitArray ( )
QBitmap& QVariant::asBitmap ( )
QBitmap & QVariant::asBitmap ( )

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.

Ver también:
toBitmap()
bool & QVariant::asBool ( )

Returns the variant's value as bool reference.

bool& QVariant::asBool ( )
QBrush & QVariant::asBrush ( )

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.

Ver también:
toBrush()
QBrush& QVariant::asBrush ( )
QByteArray & QVariant::asByteArray ( )

Tries to convert the variant to hold a QByteArray value. If that is not possible then the variant is set to an empty bytearray.

Returns a reference to the stored bytearray.

Ver también:
toByteArray()
QByteArray& QVariant::asByteArray ( )
QColor& QVariant::asColor ( )
QColor & QVariant::asColor ( )

Tries to convert the variant to hold a QColor value. If that is not possible the variant is set to an invalid color.

Returns a reference to the stored color.

Ver también:
toColor() QColor::isValid()
QColorGroup & QVariant::asColorGroup ( )

Tries to convert the variant to hold a QColorGroup 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.

Ver también:
toColorGroup()
QColorGroup& QVariant::asColorGroup ( )
QCString& QVariant::asCString ( )
QCString & QVariant::asCString ( )

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.

Ver también:
toCString()
QCursor & QVariant::asCursor ( )

Tries to convert the variant to hold a QCursor value. If that is not possible the variant is set to a default arrow cursor.

Returns a reference to the stored cursor.

Ver también:
toCursor()
QCursor& QVariant::asCursor ( )
QDate & QVariant::asDate ( )

Tries to convert the variant to hold a QDate value. If that is not possible then the variant is set to an invalid date.

Returns a reference to the stored date.

Ver también:
toDate()
QDate& QVariant::asDate ( )
QDateTime & QVariant::asDateTime ( )

Tries to convert the variant to hold a QDateTime value. If that is not possible then the variant is set to an invalid date/time.

Returns a reference to the stored date/time.

Ver también:
toDateTime()
QDateTime& QVariant::asDateTime ( )
double & QVariant::asDouble ( )

Returns the variant's value as double reference.

double& QVariant::asDouble ( )
QFont& QVariant::asFont ( )
QFont & QVariant::asFont ( )

Tries to convert the variant to hold a QFont. If that is not possible the variant is set to the application's default font.

Returns a reference to the stored font.

Ver también:
toFont()
QIconSet & QVariant::asIconSet ( )

Tries to convert the variant to hold a QIconSet value. If that is not possible the variant is set to an empty iconset.

Returns a reference to the stored iconset.

Ver también:
toIconSet()
QIconSet& QVariant::asIconSet ( )
QImage& QVariant::asImage ( )
QImage & QVariant::asImage ( )

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.

Ver también:
toImage()
int & QVariant::asInt ( )

Returns the variant's value as int reference.

int& QVariant::asInt ( )
QKeySequence & QVariant::asKeySequence ( )

Tries to convert the variant to hold a QKeySequence value. If that is not possible then the variant is set to an empty key sequence.

Returns a reference to the stored key sequence.

Ver también:
toKeySequence()
QKeySequence& QVariant::asKeySequence ( )
QValueList< QVariant > & QVariant::asList ( )

Returns the variant's value as variant list reference.

Note that if you want to iterate over the list, you should iterate over a copy, e.g.

    QValueList<QVariant> list = myVariant.asList();
    QValueList<QVariant>::Iterator it = list.begin();
    while( it != list.end() ) {
        myProcessing( *it );
        ++it;
    }
QValueList<QVariant>& QVariant::asList ( )
Q_LLONG & QVariant::asLongLong ( )

Returns the variant's value as long long reference.

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

Returns the variant's value as variant map reference.

Note that if you want to iterate over the map, you should iterate over a copy, e.g.

    QMap<QString, QVariant> map = myVariant.asMap();
    QMap<QString, QVariant>::Iterator it = map.begin();
    while( it != map.end() ) {
        myProcessing( *it );
        ++it;
    }
QMap<QString,QVariant>& QVariant::asMap ( )
QPalette& QVariant::asPalette ( )
QPalette & QVariant::asPalette ( )

Tries to convert the variant to hold a QPalette value. If that is not possible the variant is set to a palette of black colors.

Returns a reference to the stored palette.

Ver también:
toString()
QPen & QVariant::asPen ( )

Tries to convert the variant to hold a QPen value. If that is not possible then the variant is set to an empty pen.

Returns a reference to the stored pen.

Ver también:
toPen()
QPen& QVariant::asPen ( )
QPixmap& QVariant::asPixmap ( )
QPixmap & QVariant::asPixmap ( )

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.

Ver también:
toPixmap()
QPoint& QVariant::asPoint ( )
QPoint & QVariant::asPoint ( )

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.

Ver también:
toPoint()
QPointArray & QVariant::asPointArray ( )

Tries to convert the variant to hold a QPointArray value. If that is not possible the variant is set to an empty point array.

Returns a reference to the stored point array.

Ver también:
toPointArray()
QPointArray& QVariant::asPointArray ( )
QRect& QVariant::asRect ( )
QRect & QVariant::asRect ( )

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.

Ver también:
toRect()
QRegion & QVariant::asRegion ( )

Tries to convert the variant to hold a QRegion value. If that is not possible the variant is set to a null region.

Returns a reference to the stored region.

Ver también:
toRegion()
QRegion& QVariant::asRegion ( )
QSize& QVariant::asSize ( )
QSize & QVariant::asSize ( )

Tries to convert the variant to hold a QSize value. If that is not possible the variant is set to an invalid size.

Returns a reference to the stored size.

Ver también:
toSize() QSize::isValid()
QSizePolicy& QVariant::asSizePolicy ( )
QSizePolicy & QVariant::asSizePolicy ( )

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

QString& QVariant::asString ( )
QString & QVariant::asString ( )

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.

Ver también:
toString()
QStringList& QVariant::asStringList ( )
QStringList & QVariant::asStringList ( )

Tries to convert the variant to hold a QStringList 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.

    QStringList list = myVariant.asStringList();
    QStringList::Iterator it = list.begin();
    while( it != list.end() ) {
        myProcessing( *it );
        ++it;
    }
Ver también:
toStringList()
QTime & QVariant::asTime ( )

Tries to convert the variant to hold a QTime value. If that is not possible then the variant is set to an invalid time.

Returns a reference to the stored time.

Ver también:
toTime()
QTime& QVariant::asTime ( )
uint & QVariant::asUInt ( )

Returns the variant's value as unsigned int reference.

uint& QVariant::asUInt ( )
Q_ULLONG & QVariant::asULongLong ( )

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

Q_ULLONG& QVariant::asULongLong ( )
bool QVariant::canCast ( Type  ) const
bool QVariant::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.

The following casts are done automatically: 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 QVariant::cast ( Type  )
bool QVariant::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 QVariant::String, an empty point array if the requested type t is QVariant::PointArray, etc). Returns TRUE if the current type of the variant was successfully cast; otherwise returns FALSE.

Ver también:
canCast()
void QVariant::clear ( void  )

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

void QVariant::clear ( )
bool QVariant::isNull ( ) const
bool QVariant::isNull ( ) const

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

bool QVariant::isValid ( void  ) const [inline]

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

bool QVariant::isValid ( ) const
QValueListConstIterator<QVariant> QVariant::listBegin ( ) const
QValueListConstIterator< QVariant > QVariant::listBegin ( ) const [inline]

Returns an iterator to the first item in the list if the variant's type is appropriate; otherwise returns a null iterator.

QValueListConstIterator<QVariant> QVariant::listEnd ( ) const
QValueListConstIterator< QVariant > QVariant::listEnd ( ) const [inline]

Returns the end iterator for the list if the variant's type is appropriate; otherwise returns a null iterator.

void QVariant::load ( QDataStream s)

Internal function for loading a variant from stream s. Use the stream operators instead.

void QVariant::load ( QDataStream )
QMapConstIterator<QString,QVariant> QVariant::mapBegin ( ) const
QMapConstIterator< QString, QVariant > QVariant::mapBegin ( ) const [inline]

Returns an iterator to the first item in the map, if the variant's type is appropriate; otherwise returns a null iterator.

QMapConstIterator<QString,QVariant> QVariant::mapEnd ( ) const
QMapConstIterator< QString, QVariant > QVariant::mapEnd ( ) const [inline]

Returns the end iterator for the map, if the variant's type is appropriate; otherwise returns a null iterator.

QMapConstIterator<QString,QVariant> QVariant::mapFind ( const QString ) const
QMapConstIterator< QString, QVariant > QVariant::mapFind ( const QString key) const [inline]

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.

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

Converts the string representation of the storage type given in name, to its enum representation.

If the string representation cannot be converted to any enum representation, the variant is set to Invalid.

static Type QVariant::nameToType ( const char *  name) [static]
bool QVariant::operator!= ( const QVariant ) const
bool QVariant::operator!= ( const QVariant v) const

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

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

Assigns the value of the variant variant to this variant.

This is a deep copy of the variant, but note that if the variant holds an explicitly shared type such as QImage, a shallow copy is performed.

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

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

bool QVariant::operator== ( const QVariant ) const
void * QVariant::rawAccess ( void *  ptr = 0,
Type  typ = Invalid,
bool  deepCopy = FALSE 
)
void* QVariant::rawAccess ( void *  ptr = 0,
Type  typ = Invalid,
bool  deepCopy = FALSE 
)
void QVariant::save ( QDataStream s) const

Internal function for saving a variant to the stream s. Use the stream operators instead.

void QVariant::save ( QDataStream ) const
QValueListConstIterator<QString> QVariant::stringListBegin ( ) const
QValueListConstIterator< QString > QVariant::stringListBegin ( ) const [inline]

Returns an iterator to the first string in the list if the variant's type is StringList; otherwise returns a null iterator.

QValueListConstIterator<QString> QVariant::stringListEnd ( ) const
QValueListConstIterator< QString > QVariant::stringListEnd ( ) const [inline]

Returns the end iterator for the list if the variant's type is StringList; otherwise returns a null iterator.

const QBitArray QVariant::toBitArray ( ) const

Returns the variant as a QBitArray if the variant has type() BitArray; otherwise returns an empty bitarray.

Ver también:
asBitArray()
const QBitArray QVariant::toBitArray ( ) const
const QBitmap QVariant::toBitmap ( ) const

Returns the variant as a QBitmap if the variant has type() Bitmap; otherwise returns a null QBitmap.

Ver también:
asBitmap()
const QBitmap QVariant::toBitmap ( ) const
bool QVariant::toBool ( ) const
bool QVariant::toBool ( ) const

Returns the variant as a bool if the variant can be cast to Bool; otherWise returns FALSE.

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.

Ver también:
asBool(), canCast()
const QBrush QVariant::toBrush ( ) const
const QBrush QVariant::toBrush ( ) const

Returns the variant as a QBrush if the variant has type() Brush; otherwise returns a default brush (with all black colors).

Ver también:
asBrush()
const QByteArray QVariant::toByteArray ( ) const

Returns the variant as a QByteArray if the variant can be cast to a ByteArray; otherwise returns an empty bytearray.

Ver también:
asByteArray(), canCast()
const QByteArray QVariant::toByteArray ( ) const
const QColor QVariant::toColor ( ) const

Returns the variant as a QColor if the variant can be cast to Color; otherwise returns an invalid color.

Ver también:
asColor(), canCast()
const QColor QVariant::toColor ( ) const
const QColorGroup QVariant::toColorGroup ( ) const

Returns the variant as a QColorGroup if the variant has type() ColorGroup; otherwise returns a completely black color group.

Ver también:
asColorGroup()
const QColorGroup QVariant::toColorGroup ( ) const
const QCString QVariant::toCString ( ) const

Returns the variant as a QCString if the variant can be cast to a CString; otherwise returns 0.

Ver también:
asCString(), canCast()
const QCString QVariant::toCString ( ) const
const QCursor QVariant::toCursor ( ) const

Returns the variant as a QCursor if the variant has type() Cursor; otherwise returns the default arrow cursor.

Ver también:
asCursor()
const QCursor QVariant::toCursor ( ) const
const QDate QVariant::toDate ( ) const
const QDate QVariant::toDate ( ) const

Returns the variant as a QDate if the variant can be cast to Date; otherwise returns an invalid date.

Note that if the type() is String, CString or ByteArray an invalid date will be returned if the string cannot be parsed as a Qt::ISODate format date.

Ver también:
asDate(), canCast()
const QDateTime QVariant::toDateTime ( ) const
const QDateTime QVariant::toDateTime ( ) const

Returns the variant as a QDateTime if the variant can be cast to DateTime; otherwise returns an invalid QDateTime.

Note that if the type() is String, CString or ByteArray an invalid QDateTime will be returned if the string cannot be parsed as a Qt::ISODate format date/time.

Ver también:
asDateTime()
double QVariant::toDouble ( bool ok = 0) const

Returns the variant as a double if the variant can be cast to Double; otherwise returns 0.0.

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.

Ver también:
asDouble(), canCast()
double QVariant::toDouble ( bool ok = 0) const
const QFont QVariant::toFont ( ) const

Returns the variant as a QFont if the variant can be cast to Font; otherwise returns the application's default font.

Ver también:
asFont(), canCast()
const QFont QVariant::toFont ( ) const
const QIconSet QVariant::toIconSet ( ) const
const QIconSet QVariant::toIconSet ( ) const

Returns the variant as a QIconSet if the variant has type() IconSet; otherwise returns an icon set of null pixmaps.

Ver también:
asIconSet()
const QImage QVariant::toImage ( ) const

Returns the variant as a QImage if the variant has type() Image; otherwise returns a null image.

Ver también:
asImage()
const QImage QVariant::toImage ( ) const
int QVariant::toInt ( bool ok = 0) const

Returns the variant as an int if the variant can be cast to Int; otherwise returns 0.

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.

Ver también:
asInt(), canCast()
int QVariant::toInt ( bool ok = 0) const
const QKeySequence QVariant::toKeySequence ( ) const

Returns the variant as a QKeySequence if the variant can be cast to a KeySequence; otherwise returns an empty key sequence.

Ver también:
asKeySequence(), canCast()
const QKeySequence QVariant::toKeySequence ( ) const
const QValueList<QVariant> QVariant::toList ( ) const
const QValueList< QVariant > QVariant::toList ( ) const

Returns the variant as a QValueList<QVariant> if the variant has type() List or StringList; otherwise returns an empty list.

Note that if you want to iterate over the list, you should iterate over a copy, e.g.

    QValueList<QVariant> list = myVariant.toList();
    QValueList<QVariant>::Iterator it = list.begin();
    while( it != list.end() ) {
        myProcessing( *it );
        ++it;
    }
Ver también:
asList()
Q_LLONG QVariant::toLongLong ( bool ok = 0) const
Q_LLONG QVariant::toLongLong ( bool ok = 0) const

Returns the variant as a long long int if the variant can be cast to LongLong; otherwise returns 0.

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.

Ver también:
asLongLong(), canCast()
const QMap< QString, QVariant > QVariant::toMap ( ) const

Returns the variant as a QMap<QString,QVariant> if the variant has type() Map; otherwise returns an empty map.

Note that if you want to iterate over the map, you should iterate over a copy, e.g.

    QMap<QString, QVariant> map = myVariant.toMap();
    QMap<QString, QVariant>::Iterator it = map.begin();
    while( it != map.end() ) {
        myProcessing( *it );
        ++it;
    }
Ver también:
asMap()
const QMap<QString,QVariant> QVariant::toMap ( ) const
const QPalette QVariant::toPalette ( ) const
const QPalette QVariant::toPalette ( ) const

Returns the variant as a QPalette if the variant has type() Palette; otherwise returns a completely black palette.

Ver también:
asPalette()
const QPen QVariant::toPen ( ) const

Returns the variant as a QPen if the variant has type() Pen; otherwise returns an empty QPen.

Ver también:
asPen()
const QPen QVariant::toPen ( ) const
const QPixmap QVariant::toPixmap ( ) const
const QPixmap QVariant::toPixmap ( ) const

Returns the variant as a QPixmap if the variant has type() Pixmap; otherwise returns a null pixmap.

Ver también:
asPixmap()
const QPoint QVariant::toPoint ( ) const

Returns the variant as a QPoint if the variant has type() Point; otherwise returns a point (0, 0).

Ver también:
asPoint()
const QPoint QVariant::toPoint ( ) const
const QPointArray QVariant::toPointArray ( ) const
const QPointArray QVariant::toPointArray ( ) const

Returns the variant as a QPointArray if the variant has type() PointArray; otherwise returns an empty QPointArray.

Ver también:
asPointArray()
const QRect QVariant::toRect ( ) const

Returns the variant as a QRect if the variant has type() Rect; otherwise returns an empty rectangle.

Ver también:
asRect()
const QRect QVariant::toRect ( ) const
const QRegion QVariant::toRegion ( ) const
const QRegion QVariant::toRegion ( ) const

Returns the variant as a QRegion if the variant has type() Region; otherwise returns an empty QRegion.

Ver también:
asRegion()
const QSize QVariant::toSize ( ) const

Returns the variant as a QSize if the variant has type() Size; otherwise returns an invalid size.

Ver también:
asSize()
const QSize QVariant::toSize ( ) const
QSizePolicy QVariant::toSizePolicy ( ) const
QSizePolicy QVariant::toSizePolicy ( ) const

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

const QString QVariant::toString ( ) const

Returns the variant as a QString if the variant can be cast to String, otherwise returns QString::null.

Ver también:
asString(), canCast()
const QString QVariant::toString ( ) const
const QStringList QVariant::toStringList ( ) const
const QStringList QVariant::toStringList ( ) const

Returns the variant as a QStringList if the variant has type() StringList or List of a type that can be converted to QString; otherwise returns an empty list.

Note that if you want to iterate over the list, you should iterate over a copy, e.g.

    QStringList list = myVariant.toStringList();
    QStringList::Iterator it = list.begin();
    while( it != list.end() ) {
        myProcessing( *it );
        ++it;
    }
Ver también:
asStringList()
const QTime QVariant::toTime ( ) const

Returns the variant as a QTime if the variant can be cast to Time; otherwise returns an invalid date.

Note that if the type() is String, CString or ByteArray an invalid time will be returned if the string cannot be parsed as a Qt::ISODate format time.

Ver también:
asTime()
const QTime QVariant::toTime ( ) const
uint QVariant::toUInt ( bool ok = 0) const
uint QVariant::toUInt ( bool ok = 0) const

Returns the variant as an unsigned int if the variant can be cast to UInt; otherwise returns 0.

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.

Ver también:
asUInt(), canCast()
Q_ULLONG QVariant::toULongLong ( bool ok = 0) const
Q_ULLONG QVariant::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.

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.

Ver también:
asULongLong(), canCast()
QVariant::Type QVariant::type ( ) const [inline]

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.

Type QVariant::type ( ) const
const char* QVariant::typeName ( ) const
const char * QVariant::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, "QFont", "QString", or "QValueList<QVariant>". An Invalid variant returns 0.

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

Converts the enum representation of the storage type, typ, to its string representation.

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

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'