Qt logo

QVariant Class Reference


Acts like a union for the most common Qt data types. More...

#include <qvariant.h>

Inherits QShared.

List of all member functions.

Public Members

Static Public Members

Protected Members


Detailed Description

Acts like a union for the most common Qt data types.

Unfortunately one can not use C++ unions with classes that have constructors and destructors since the compiler and the runtime library could not determine which destructor to call.

To come around this QVariant can store the most common Qt and C++ data types. Like every union it can hold one value of a certain type at a time.


Member Type Documentation

QVariant::Type

This enum type defines the types of variable that a QVariant can contain. Here is a lost of the supported types, and what they indicate that the relevant QVariant object contains : Note that Qt's idea of bool depends on the compiler. qglobal.h has the system-dependent definition of bool.

Member Function Documentation

QVariant::QVariant ()

Creates an invalid variant.

QVariant::QVariant ( QDataStream & s )

Reads the variant from the data stream.

QVariant::QVariant ( bool val )

Creates a new variant with a boolean value.

QVariant::QVariant ( const QBrush & val )

Creates a new variant with a brush value.

QVariant::QVariant ( const QColor & val )

Creates a new variant with a color value.

QVariant::QVariant ( const QColorGroup & val )

Creates a new variant with a color group value.

QVariant::QVariant ( const QCString & val )

Creates a new variant with a c-string value.

QVariant::QVariant ( const QFont & val )

Creates a new variant with a font value.

QVariant::QVariant ( const QIconSet & val )

Creates a new variant with an empty iconset.

QVariant::QVariant ( const QImage & val )

Creates a new variant with an image value.

QVariant::QVariant ( const QPalette & val )

Creates a new variant with a color palette value.

QVariant::QVariant ( const QPixmap & val )

Creates a new variant with a pixmap value.

QVariant::QVariant ( const QPoint & val )

Creates a new variant with a point value.

QVariant::QVariant ( const QRect & val )

Creates a new variant with a rect value.

QVariant::QVariant ( const QSize & val )

Creates a new variant with a size value.

QVariant::QVariant ( const QString & val )

Creates a new variant with a string value.

QVariant::QVariant ( const QStringList & val )

Creates a new variant with a string list value.

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

Creates a new variant with a floating point list value.

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

Creates a new variant with a integer list value.

QVariant::QVariant ( const QVariant & p )

Constructs a deep copy of the variant passed as argument to this constructor.

QVariant::QVariant ( const char * val )

Creates a new variant with a c-string value.

QVariant::QVariant ( double val )

Creates a new variant with a floating point value.

QVariant::QVariant ( int val )

Creates a new variant with an integer value.

QVariant::~QVariant () [virtual]

Destroys the QVariant and the contained object.

Note that subclasses that re-implement clear() should reimplement the destructor to call clear(). This constructor calls clear(), but since it is the destructor, QVariant::clear() is called rather than any subclass.

void QVariant::clear () [virtual protected]

De-allocate, based on the type, producing an Invalid variant.

bool QVariant::isValid () const

Returns TRUE if the storage type of this variant is QVariant::Invalid.

void QVariant::load ( QDataStream & s ) [virtual]

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

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

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

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

Assigns the value of one variant to another. This creates a deep copy.

void QVariant::save ( QDataStream & s ) const [virtual]

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

void QVariant::setValue ( bool val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QBrush & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QColor & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QColorGroup & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QCString & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QFont & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QIconSet & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QImage & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QPalette & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QPixmap & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QPoint & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QRect & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QSize & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QString & val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( const QStringList & val )

Changes the value of this variant. The previous value is dropped. This function creates a copy of the list. This is very fast since QStringList is implicit shared.

void QVariant::setValue ( const QValueList<double> & val )

Changes the value of this variant. The previous value is dropped. This function creates a copy of the list. This is very fast since QStringList is implicit shared.

void QVariant::setValue ( const QValueList<int> & val )

Changes the value of this variant. The previous value is dropped. This function creates a copy of the list. This is very fast since QStringList is implicit shared.

void QVariant::setValue ( const char * val )

Changes the value of this variant. The previous value is dropped. The Variant creates a copy of the passed string.

void QVariant::setValue ( double val )

Changes the value of this variant. The previous value is dropped.

void QVariant::setValue ( int val )

Changes the value of this variant. The previous value is dropped.

Type QVariant::type () const

Returns the stoarge type of the value stored in the variant currently.

const char* QVariant::typeName () const [virtual]

Returns the type stored in the variant currently in ASCII format. The returned strings describe the C++ datatype used to store the data, for example "QFont", "QString" or "QValueList".

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

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


Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):


This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.


Copyright İ 1999 Troll TechTrademarks
Qt version 2.1.0 (pre-release)