Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QVariant Class Reference

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

    #include <QVariant>

Inherits QCoreVariant.

- List of all members, including inherited members
- Compatibility members

### Public Functions

- QVariant ()
- QVariant ( const QDateTime & val )
- QVariant ( const QList<QCoreVariant> & val )
- QVariant ( const QMap<QString, QCoreVariant> & val )
- QVariant ( const QList<QVariant> & val )
- QVariant ( const QMap<QString, QVariant> & val )
- QVariant ( const QSize & val )
- QVariant ( const QRect & val )
- QVariant ( const QPoint & val )
- QVariant ( const QFont & val )
- QVariant ( const QPixmap & val )
- QVariant ( const QImage & val )
- QVariant ( const QBrush & val )
- QVariant ( const QColor & val )
- QVariant ( const QPalette & val )
- QVariant ( const QIcon & val )
- QVariant ( const QPointArray & val )
- QVariant ( const QRegion & val )
- QVariant ( const QBitmap & val )
- QVariant ( const QCursor & val )
- QVariant ( const QKeySequence & val )
- QVariant ( const QPen & val )
- QVariant ( const QSizePolicy & val )
- QVariant ( const QCoreVariant & other )
- QVariant ( const QVariant & other )
- QVariant ( int val )
- QVariant ( uint val )
- QVariant ( Q_LONGLONG val )
- QVariant ( Q_ULONGLONG val )
- QVariant ( double val )
- QVariant ( bool val )
- QVariant ( const char * val )
- QVariant ( const QByteArray & val )
- QVariant ( const QBitArray & val )
- QVariant ( const QString & val )
- QVariant ( const QLatin1String & val )
- QVariant ( const QStringList & val )
- QVariant ( const QDate & val )
- QVariant ( const QTime & val )
- QBitmap toBitmap () const
- QBrush toBrush () const
- QColor toColor () const
- QCursor toCursor () const
- QFont toFont () const
- QIcon toIcon () const
- QIcon toIconSet () const
- const QImage toImage () const
- QKeySequence toKeySequence () const
- QPalette toPalette () const
- QPen toPen () const
- QPixmap toPixmap () const
- QPoint toPoint () const
- const QPointArray toPointArray () const
- QRect toRect () const
- QRegion toRegion () const
- QSize toSize () const
- QSizePolicy toSizePolicy () const

- 26 public functions inherited from QCoreVariant

### Static Public Members

- 2 static public members inherited from QCoreVariant

### Protected Functions

- void create ( int type, const void * copy )

## Detailed Description

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

This class is derived from QCoreVariant. It includes all the types from QCoreVariant and additional types which make sense for GUI applications.

## Member Function Documentation

### QVariant::QVariant ()

Constructs an invalid variant.

### QVariant::QVariant ( const QDateTime & val )

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

### QVariant::QVariant ( const QList<QCoreVariant> & val )

Constructs a new variant that holds the list of variants given in val.

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

Constructs a new variant that holds a map whose keys are strings and whose values are variants, as given in val.

### QVariant::QVariant ( const QList<QVariant> & val )

Constructs a new variant that holds the list of variants given in val.

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

Constructs a new variant that holds a map whose keys are strings and whose values are variants, as given in val.

### QVariant::QVariant ( const QSize & val )

Constructs a new variant with a size value of val.

### QVariant::QVariant ( const QRect & val )

Constructs a new variant with a rect value of val.

### QVariant::QVariant ( const QPoint & val )

Constructs a new variant with a point value of val.

### QVariant::QVariant ( const QFont & val )

Constructs a new variant with a font value of val.

### QVariant::QVariant ( const QPixmap & val )

Constructs a new variant with a pixmap value of val.

### QVariant::QVariant ( const QImage & val )

Constructs a new variant with an image value of 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 of val.

### QVariant::QVariant ( const QColor & val )

Constructs a new variant with a color value of val.

### QVariant::QVariant ( const QPalette & val )

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

### QVariant::QVariant ( const QIcon & val )

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

### QVariant::QVariant ( const QPointArray & val )

Constructs a new variant with a point array value of 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 of val.

### QVariant::QVariant ( const QBitmap & val )

Constructs a new variant with a bitmap value of val.

### QVariant::QVariant ( const QCursor & val )

Constructs a new variant with a cursor value of val.

### QVariant::QVariant ( const QKeySequence & val )

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

### QVariant::QVariant ( const QPen & val )

Constructs a new variant with a pen value of val.

### QVariant::QVariant ( const QSizePolicy & val )

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

### QVariant::QVariant ( const QCoreVariant & other )

Constructs a variant with the value of other.

### QVariant::QVariant ( const QVariant & other )

Constructs a variant with the value of other.

### QVariant::QVariant ( int val )

Constructs a new variant with an integer value of val.

### QVariant::QVariant ( uint val )

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

### QVariant::QVariant ( Q_LONGLONG val )

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

### QVariant::QVariant ( Q_ULONGLONG val )

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

### QVariant::QVariant ( double val )

Constructs a new variant with a double value of val.

### QVariant::QVariant ( bool val )

Constructs a new variant with a boolean value of val.

### QVariant::QVariant ( const char * val )

Constructs a new variant with a byte array value of val.

### QVariant::QVariant ( const QByteArray & val )

Constructs a new variant with a byte array value of val.

### QVariant::QVariant ( const QBitArray & val )

Constructs a new variant with a bit array value of val.

### QVariant::QVariant ( const QString & val )

Constructs a new variant with a string value of val.

### QVariant::QVariant ( const QLatin1String & val )

Constructs a new variant with a string value of val.

### QVariant::QVariant ( const QStringList & val )

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

### QVariant::QVariant ( const QDate & val )

Constructs a new variant with a date value of val.

### QVariant::QVariant ( const QTime & val )

Constructs a new variant with a time value of val.

### void QVariant::create ( int type, const void * copy ) `[protected]`

### QBitmap QVariant::toBitmap () const

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

### 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).

### QColor QVariant::toColor () const

Returns the variant as a QColor if the variant has type() Color; otherwise returns an invalid color.

### QCursor QVariant::toCursor () const

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

### QFont QVariant::toFont () const

Returns the variant as a QFont if the variant has type() Font; otherwise returns the application's default font.

### QIcon QVariant::toIcon () const

Returns the variant as a QIcon if the variant has type() Icon; otherwise returns a null QIcon.

### QIcon QVariant::toIconSet () const

Use toIcon() instead.

### const QImage QVariant::toImage () const

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

### QKeySequence QVariant::toKeySequence () const

Returns the variant as a QKeySequence if the variant has type() KeySequence, Int or String; otherwise returns an empty key sequence.

Note that not all Ints and Strings are valid key sequences and in such cases an empty key sequence will be returned.

### QPalette QVariant::toPalette () const

Returns the variant as a QPalette if the variant has type() Palette; otherwise returns a copy of the application's default palette.

### QPen QVariant::toPen () const

Returns the variant as a QPen if the variant has type() Pen; otherwise returns a default pen that will draw 1-pixel wide solid black lines.

### QPixmap QVariant::toPixmap () const

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

### QPoint QVariant::toPoint () const

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

### const QPointArray QVariant::toPointArray () const

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

### QRect QVariant::toRect () const

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

### QRegion QVariant::toRegion () const

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

### QSize QVariant::toSize () const

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

### QSizePolicy QVariant::toSizePolicy () const

Returns the variant as a QSizePolicy if the variant has type() SizePolicy; otherwise returns a minimally initialized QSizePolicy.