- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends

# QVariant Class Reference

Search for all occurrences

## Detailed Description

Definition at line 100 of file qvariant.h.

`#include <qvariant.h>`

List of all members.

## Classes
struct | Handler
struct | Private
struct | PrivateShared
## Public Types
enum | Type { Invalid = 0, Bool = 1, Int = 2, UInt = 3, LongLong = 4, ULongLong = 5, Double = 6, Char = 7, Map = 8, List = 9, String = 10, StringList = 11, ByteArray = 12, BitArray = 13, Date = 14, Time = 15, DateTime = 16, Url = 17, Locale = 18, Rect = 19, RectF = 20, Size = 21, SizeF = 22, Line = 23, LineF = 24, Point = 25, PointF = 26, RegExp = 27, Hash = 28, EasingCurve = 29, LastCoreType = EasingCurve, Font = 64, Pixmap = 65, Brush = 66, Color = 67, Palette = 68, Icon = 69, Image = 70, Polygon = 71, Region = 72, Bitmap = 73, Cursor = 74, SizePolicy = 75, KeySequence = 76, Pen = 77, TextLength = 78, TextFormat = 79, Matrix = 80, Transform = 81, Matrix4x4 = 82, Vector2D = 83, Vector3D = 84, Vector4D = 85, Quaternion = 86, LastGuiType = Quaternion, UserType = 127, LastType = 0xffffffff }
typedef void(* | f_construct )(Private *, const void *)
typedef void(* | f_clear )(Private *)
typedef bool(* | f_null )(const Private *)
typedef void(* | f_load )(Private *, QDataStream &)
typedef void(* | f_save )(const Private *, QDataStream &)
typedef bool(* | f_compare )(const Private *, const Private *)
typedef bool(* | f_convert )(const QVariant::Private *d, Type t, void *, bool *)
typedef bool(* | f_canConvert )(const QVariant::Private *d, Type t)
typedef void(* | f_debugStream )(QDebug, const QVariant &)
typedef Private | DataPtr
## Public Member Functions
| QVariant ()
| ~QVariant ()
| QVariant (Type type)
| QVariant (int typeOrUserType, const void *copy)
| QVariant (int typeOrUserType, const void *copy, uint flags)
| QVariant (const QVariant &other)
| QVariant (QDataStream &s)
| QVariant (int i)
| QVariant (uint ui)
| QVariant (qlonglong ll)
| QVariant (qulonglong ull)
| QVariant (bool b)
| QVariant (double d)
| QVariant (float f)
QT_ASCII_CAST_WARN_CONSTRUCTOR | QVariant (const char *str)
| QVariant (const QByteArray &bytearray)
| QVariant (const QBitArray &bitarray)
| QVariant (const QString &string)
| QVariant (const QLatin1String &string)
| QVariant (const QStringList &stringlist)
| QVariant (const QChar &qchar)
| QVariant (const QDate &date)
| QVariant (const QTime &time)
| QVariant (const QDateTime &datetime)
| QVariant (const QList< QVariant > &list)
| QVariant (const QMap< QString, QVariant > &map)
| QVariant (const QHash< QString, QVariant > &hash)
| QVariant (const QSize &size)
| QVariant (const QSizeF &size)
| QVariant (const QPoint &pt)
| QVariant (const QPointF &pt)
| QVariant (const QLine &line)
| QVariant (const QLineF &line)
| QVariant (const QRect &rect)
| QVariant (const QRectF &rect)
| QVariant (const QUrl &url)
| QVariant (const QLocale &locale)
| QVariant (const QRegExp &regExp)
| QVariant (const QEasingCurve &easing)
| QVariant (Qt::GlobalColor color)
QVariant & | operator= (const QVariant &other)
Type | type () const
int | userType () const
const char * | typeName () const
bool | canConvert (Type t) const
bool | convert (Type t)
bool | isValid () const
bool | isNull () const
void | clear ()
void | detach ()
bool | isDetached () const
int | toInt (bool *ok=0) const
uint | toUInt (bool *ok=0) const
qlonglong | toLongLong (bool *ok=0) const
qulonglong | toULongLong (bool *ok=0) const
bool | toBool () const
double | toDouble (bool *ok=0) const
float | toFloat (bool *ok=0) const
qreal | toReal (bool *ok=0) const
QByteArray | toByteArray () const
QBitArray | toBitArray () const
QString | toString () const
QStringList | toStringList () const
QChar | toChar () const
QDate | toDate () const
QTime | toTime () const
QDateTime | toDateTime () const
QList< QVariant > | toList () const
QMap< QString, QVariant > | toMap () const
QHash< QString, QVariant > | toHash () const
QPoint | toPoint () const
QPointF | toPointF () const
QRect | toRect () const
QSize | toSize () const
QSizeF | toSizeF () const
QLine | toLine () const
QLineF | toLineF () const
QRectF | toRectF () const
QUrl | toUrl () const
QLocale | toLocale () const
QRegExp | toRegExp () const
QEasingCurve | toEasingCurve () const
void | load (QDataStream &ds)
void | save (QDataStream &ds) const
void * | data ()
const void * | constData () const
const void * | data () const
template<typename T >
void | setValue (const T &value)
template<typename T >
T | value () const
template<typename T >
bool | canConvert () const
bool | operator== (const QVariant &v) const
bool | operator!= (const QVariant &v) const
DataPtr & | data_ptr ()
## Static Public Member Functions
static const char * | typeToName (Type type)
static Type | nameToType (const char *name)
template<typename T >
static QVariant | fromValue (const T &value)
## Protected Member Functions
void | create (int type, const void *copy)
bool | cmp (const QVariant &other) const
## Protected Attributes
Private | d
## Static Protected Attributes
static const Handler * | handler
## Friends
bool | qvariant_cast_helper (const QVariant &, QVariant::Type, void *)
int | qRegisterGuiVariant ()
int | qUnregisterGuiVariant ()
bool | operator== (const QVariant &, const QVariantComparisonHelper &)
Q_CORE_EXPORT QDebug | operator<< (QDebug, const QVariant &)

## Member Typedef Documentation

typedef void(* f_construct)(Private *, const void *)

Search for all occurrences

Definition at line 382 of file qvariant.h.

typedef void(* f_clear)(Private *)

Search for all occurrences

Definition at line 383 of file qvariant.h.

typedef bool(* f_null)(const Private *)

Search for all occurrences

Definition at line 384 of file qvariant.h.

typedef void(* f_load)(Private *, QDataStream &)

Search for all occurrences

Definition at line 386 of file qvariant.h.

typedef void(* f_save)(const Private *, QDataStream &)

Search for all occurrences

Definition at line 387 of file qvariant.h.

typedef bool(* f_compare)(const Private *, const Private *)

Search for all occurrences

Definition at line 389 of file qvariant.h.

typedef bool(* f_convert)(const QVariant::Private *d, Type t, void *, bool *)

Search for all occurrences

Definition at line 390 of file qvariant.h.

typedef bool(* f_canConvert)(const QVariant::Private *d, Type t)

Search for all occurrences

Definition at line 391 of file qvariant.h.

typedef void(* f_debugStream)(QDebug, const QVariant &)

Search for all occurrences

Definition at line 392 of file qvariant.h.

typedef Private DataPtr

Search for all occurrences

Definition at line 443 of file qvariant.h.

## Member Enumeration Documentation

enum Type

Search for all occurrences

Enumerator:

  Invalid | Search for all occurrences
  Bool | Search for all occurrences
  Int | Search for all occurrences
  UInt | Search for all occurrences
  LongLong | Search for all occurrences
  ULongLong | Search for all occurrences
  Double | Search for all occurrences
  Char | Search for all occurrences
  Map | Search for all occurrences
  List | Search for all occurrences
  String | Search for all occurrences
  StringList | Search for all occurrences
  ByteArray | Search for all occurrences
  BitArray | Search for all occurrences
  Date | Search for all occurrences
  Time | Search for all occurrences
  DateTime | Search for all occurrences
  Url | Search for all occurrences
  Locale | Search for all occurrences
  Rect | Search for all occurrences
  RectF | Search for all occurrences
  Size | Search for all occurrences
  SizeF | Search for all occurrences
  Line | Search for all occurrences
  LineF | Search for all occurrences
  Point | Search for all occurrences
  PointF | Search for all occurrences
  RegExp | Search for all occurrences
  Hash | Search for all occurrences
  EasingCurve | Search for all occurrences
  LastCoreType | Search for all occurrences
  Font | Search for all occurrences
  Pixmap | Search for all occurrences
  Brush | Search for all occurrences
  Color | Search for all occurrences
  Palette | Search for all occurrences
  Icon | Search for all occurrences
  Image | Search for all occurrences
  Polygon | Search for all occurrences
  Region | Search for all occurrences
  Bitmap | Search for all occurrences
  Cursor | Search for all occurrences
  SizePolicy | Search for all occurrences
  KeySequence | Search for all occurrences
  Pen | Search for all occurrences
  TextLength | Search for all occurrences
  TextFormat | Search for all occurrences
  Matrix | Search for all occurrences
  Transform | Search for all occurrences
  Matrix4x4 | Search for all occurrences
  Vector2D | Search for all occurrences
  Vector3D | Search for all occurrences
  Vector4D | Search for all occurrences
  Quaternion | Search for all occurrences
  LastGuiType | Search for all occurrences
  UserType | Search for all occurrences
  LastType | Search for all occurrences

Definition at line 103 of file qvariant.h.

                  {
            Invalid = 0,

            Bool = 1,
            Int = 2,
            UInt = 3,
            LongLong = 4,
            ULongLong = 5,
            Double = 6,
            Char = 7,
            Map = 8,
            List = 9,
            String = 10,
            StringList = 11,
            ByteArray = 12,
            BitArray = 13,
            Date = 14,
            Time = 15,
            DateTime = 16,
            Url = 17,
            Locale = 18,
            Rect = 19,
            RectF = 20,
            Size = 21,
            SizeF = 22,
            Line = 23,
            LineF = 24,
            Point = 25,
            PointF = 26,
            RegExp = 27,
            Hash = 28,
            EasingCurve = 29,
            LastCoreType = EasingCurve,

            // value 62 is internally reserved
    #ifdef QT3_SUPPORT
            ColorGroup = 63,
    #endif
            Font = 64,
            Pixmap = 65,
            Brush = 66,
            Color = 67,
            Palette = 68,
            Icon = 69,
            Image = 70,
            Polygon = 71,
            Region = 72,
            Bitmap = 73,
            Cursor = 74,
            SizePolicy = 75,
            KeySequence = 76,
            Pen = 77,
            TextLength = 78,
            TextFormat = 79,
            Matrix = 80,
            Transform = 81,
            Matrix4x4 = 82,
            Vector2D = 83,
            Vector3D = 84,
            Vector4D = 85,
            Quaternion = 86,
            LastGuiType = Quaternion,

            UserType = 127,
    #ifdef QT3_SUPPORT
            IconSet = Icon,
            CString = ByteArray,
            PointArray = Polygon,
    #endif
            LastType = 0xffffffff // need this so that gcc >= 3.4 allocates 32 bits for Type
        };

## Constructor & Destructor Documentation

QVariant | ( |  | ) | `[inline]`

Definition at line 488 of file qvariant.h.

    {}

~QVariant | ( |  | ) |

QVariant | ( | Type | type | ) |

QVariant | ( | int | typeOrUserType,
|  | const void * | copy
| ) |  |

QVariant | ( | int | typeOrUserType,
|  | const void * | copy,
|  | uint | flags
| ) |  |

QVariant | ( | const QVariant & | other | ) |

QVariant | ( | QDataStream & | s | ) |

QVariant | ( | int | i | ) |

QVariant | ( | uint | ui | ) |

QVariant | ( | qlonglong | ll | ) |

QVariant | ( | qulonglong | ull | ) |

QVariant | ( | bool | b | ) |

QVariant | ( | double | d | ) |

QVariant | ( | float | f | ) | `[inline]`

Definition at line 192 of file qvariant.h.

    { d.is_null = false; d.type = QMetaType::Float; d.data.f = f; }

QT_ASCII_CAST_WARN_CONSTRUCTOR QVariant | ( | const char * | str | ) |

QVariant | ( | const QByteArray & | bytearray | ) |

QVariant | ( | const QBitArray & | bitarray | ) |

QVariant | ( | const QString & | string | ) |

QVariant | ( | const QLatin1String & | string | ) |

QVariant | ( | const QStringList & | stringlist | ) |

QVariant | ( | const QChar & | qchar | ) |

QVariant | ( | const QDate & | date | ) |

QVariant | ( | const QTime & | time | ) |

QVariant | ( | const QDateTime & | datetime | ) |

QVariant | ( | const QList< QVariant > & | list | ) |

QVariant | ( | const QMap< QString, QVariant > & | map | ) |

QVariant | ( | const QHash< QString, QVariant > & | hash | ) |

QVariant | ( | const QSize & | size | ) |

QVariant | ( | const QSizeF & | size | ) |

QVariant | ( | const QPoint & | pt | ) |

QVariant | ( | const QPointF & | pt | ) |

QVariant | ( | const QLine & | line | ) |

QVariant | ( | const QLineF & | line | ) |

QVariant | ( | const QRect & | rect | ) |

QVariant | ( | const QRectF & | rect | ) |

QVariant | ( | const QUrl & | url | ) |

QVariant | ( | const QLocale & | locale | ) |

QVariant | ( | const QRegExp & | regExp | ) |

QVariant | ( | const QEasingCurve & | easing | ) |

QVariant | ( | Qt::GlobalColor | color | ) |

## Member Function Documentation

QVariant& operator= | ( | const QVariant & | other | ) |

Type type | ( |  | ) | const

Search for all occurrences

int userType | ( |  | ) | const

Search for all occurrences

const char* typeName | ( |  | ) | const

Search for all occurrences

bool canConvert | ( | Type | t | ) | const

Search for all occurrences

bool convert | ( | Type | t | ) |

Search for all occurrences

bool isValid | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 489 of file qvariant.h.

    { return d.type != Invalid; }

bool isNull | ( |  | ) | const

Search for all occurrences

void clear | ( |  | ) |

Search for all occurrences

void detach | ( |  | ) |

Search for all occurrences

bool isDetached | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 543 of file qvariant.h.

    { return !d.is_shared || d.data.shared->ref == 1; }

int toInt | ( | bool * | ok = `0` | ) | const

Search for all occurrences

uint toUInt | ( | bool * | ok = `0` | ) | const

Search for all occurrences

qlonglong toLongLong | ( | bool * | ok = `0` | ) | const

Search for all occurrences

qulonglong toULongLong | ( | bool * | ok = `0` | ) | const

Search for all occurrences

bool toBool | ( |  | ) | const

Search for all occurrences

double toDouble | ( | bool * | ok = `0` | ) | const

Search for all occurrences

float toFloat | ( | bool * | ok = `0` | ) | const

Search for all occurrences

qreal toReal | ( | bool * | ok = `0` | ) | const

Search for all occurrences

QByteArray toByteArray | ( |  | ) | const

Search for all occurrences

QBitArray toBitArray | ( |  | ) | const

Search for all occurrences

QString toString | ( |  | ) | const

Search for all occurrences

QStringList toStringList | ( |  | ) | const

Search for all occurrences

QChar toChar | ( |  | ) | const

Search for all occurrences

QDate toDate | ( |  | ) | const

Search for all occurrences

QTime toTime | ( |  | ) | const

Search for all occurrences

QDateTime toDateTime | ( |  | ) | const

Search for all occurrences

QList<QVariant> toList | ( |  | ) | const

Search for all occurrences

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

Search for all occurrences

QHash<QString, QVariant> toHash | ( |  | ) | const

Search for all occurrences

QPoint toPoint | ( |  | ) | const

Search for all occurrences

QPointF toPointF | ( |  | ) | const

Search for all occurrences

QRect toRect | ( |  | ) | const

Search for all occurrences

QSize toSize | ( |  | ) | const

Search for all occurrences

QSizeF toSizeF | ( |  | ) | const

Search for all occurrences

QLine toLine | ( |  | ) | const

Search for all occurrences

QLineF toLineF | ( |  | ) | const

Search for all occurrences

QRectF toRectF | ( |  | ) | const

Search for all occurrences

QUrl toUrl | ( |  | ) | const

Search for all occurrences

QLocale toLocale | ( |  | ) | const

Search for all occurrences

QRegExp toRegExp | ( |  | ) | const

Search for all occurrences

QEasingCurve toEasingCurve | ( |  | ) | const

Search for all occurrences

void load | ( | QDataStream & | ds | ) |

Search for all occurrences

void save | ( | QDataStream & | ds | ) | const

Search for all occurrences

static const char* typeToName | ( | Type | type | ) | `[static]`

Search for all occurrences

static Type nameToType | ( | const char * | name | ) | `[static]`

Search for all occurrences

void* data | ( |  | ) |

Search for all occurrences

const void* constData | ( |  | ) | const

Search for all occurrences

const void* data | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 328 of file qvariant.h.

    { return constData(); }

void setValue | ( | const T & | value | ) | `[inline]`

Search for all occurrences

Definition at line 532 of file qvariant.h.

    { qVariantSetValue(*this, avalue); }

T value | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 335 of file qvariant.h.

        { return qVariantValue<T>(*this); }

static QVariant fromValue | ( | const T & | value | ) | `[inline, static]`

Search for all occurrences

Definition at line 339 of file qvariant.h.

        { return qVariantFromValue(value); }

bool canConvert | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 343 of file qvariant.h.

        { return qVariantCanConvert<T>(*this); }

bool operator== | ( | const QVariant & | v | ) | const `[inline]`

Definition at line 408 of file qvariant.h.

        { return cmp(v); }

bool operator!= | ( | const QVariant & | v | ) | const `[inline]`

Definition at line 410 of file qvariant.h.

        { return !cmp(v); }

void create | ( | int | type,
|  | const void * | copy
| ) |  | `[protected]`

Search for all occurrences

bool cmp | ( | const QVariant & | other | ) | const `[protected]`

Search for all occurrences

DataPtr& data_ptr | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 444 of file qvariant.h.

    { return d; }

## Friends And Related Function Documentation

bool qvariant_cast_helper | ( | const QVariant & | v,
|  | QVariant::Type | tp,
|  | void * | ptr
| ) |  | `[friend]`

Search for all occurrences

Definition at line 451 of file qvariant.h.

    { return QVariant::handler->convert(&v.d, tp, ptr, 0); }

int qRegisterGuiVariant | ( |  | ) | `[friend]`

Search for all occurrences

int qUnregisterGuiVariant | ( |  | ) | `[friend]`

Search for all occurrences

bool operator== | ( | const QVariant & | v1,
|  | const QVariantComparisonHelper & | v2
| ) |  | `[friend]`

Definition at line 565 of file qvariant.h.

    {
        return v1.cmp(*v2.v);
    }

Q_CORE_EXPORT QDebug operator<< | ( | QDebug | ,
|  | const QVariant & |
| ) |  | `[friend]`

## Member Data Documentation

Private d `[protected]`

Search for all occurrences

Definition at line 421 of file qvariant.h.

const Handler* handler `[static, protected]`

Search for all occurrences

Definition at line 423 of file qvariant.h.

The documentation for this class was generated from the following file:

- QtCore/qvariant.h

QVariant QVariant QVariant QVariant QVariant QVariant QVariant QVariant QVariant QVariant
QVariant QVariant QVariant QVariant QVariant QVariant QVariant QVariant QVariant QVariant