Obsolete Members for QVariant

The following members of class QVariant are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

Public Types

(obsolete) enum Type { Invalid, BitArray, Bitmap, Bool, Brush, …, UserType }

Public Functions

(obsolete) bool operator<(const QVariant &v) const
(obsolete) bool operator<=(const QVariant &v) const
(obsolete) bool operator>(const QVariant &v) const
(obsolete) bool operator>=(const QVariant &v) const

Related Non-Members

(obsolete) bool qVariantCanConvert(const QVariant &value)
(obsolete) QVariant qVariantFromValue(const T &value)
(obsolete) void qVariantSetValue(QVariant &variant, const T &value)
(obsolete) T qVariantValue(const QVariant &value)

Member Type Documentation

enum QVariant::Type

This enum is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QMetaType::Type instead

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

ConstantValueDescription
QVariant::InvalidQMetaType::UnknownTypeno type
QVariant::BitArrayQMetaType::QBitArraya QBitArray
QVariant::BitmapQMetaType::QBitmapa QBitmap
QVariant::BoolQMetaType::Boola bool
QVariant::BrushQMetaType::QBrusha QBrush
QVariant::ByteArrayQMetaType::QByteArraya QByteArray
QVariant::CharQMetaType::QChara QChar
QVariant::ColorQMetaType::QColora QColor
QVariant::CursorQMetaType::QCursora QCursor
QVariant::DateQMetaType::QDatea QDate
QVariant::DateTimeQMetaType::QDateTimea QDateTime
QVariant::DoubleQMetaType::Doublea double
QVariant::EasingCurveQMetaType::QEasingCurvea QEasingCurve
QVariant::UuidQMetaType::QUuida QUuid
QVariant::ModelIndexQMetaType::QModelIndexa QModelIndex
QVariant::PersistentModelIndexQMetaType::QPersistentModelIndexa QPersistentModelIndex (since 5.5)
QVariant::FontQMetaType::QFonta QFont
QVariant::HashQMetaType::QVariantHasha QVariantHash
QVariant::IconQMetaType::QIcona QIcon
QVariant::ImageQMetaType::QImagea QImage
QVariant::IntQMetaType::Intan int
QVariant::KeySequenceQMetaType::QKeySequencea QKeySequence
QVariant::LineQMetaType::QLinea QLine
QVariant::LineFQMetaType::QLineFa QLineF
QVariant::ListQMetaType::QVariantLista QVariantList
QVariant::LocaleQMetaType::QLocalea QLocale
QVariant::LongLongQMetaType::LongLonga qlonglong
QVariant::MapQMetaType::QVariantMapa QVariantMap
QVariant::MatrixQMetaType::QMatrixa QMatrix
QVariant::TransformQMetaType::QTransforma QTransform
QVariant::Matrix4x4QMetaType::QMatrix4x4a QMatrix4x4
QVariant::PaletteQMetaType::QPalettea QPalette
QVariant::PenQMetaType::QPena QPen
QVariant::PixmapQMetaType::QPixmapa QPixmap
QVariant::PointQMetaType::QPointa QPoint
QVariant::PointFQMetaType::QPointFa QPointF
QVariant::PolygonQMetaType::QPolygona QPolygon
QVariant::PolygonFQMetaType::QPolygonFa QPolygonF
QVariant::QuaternionQMetaType::QQuaterniona QQuaternion
QVariant::RectQMetaType::QRecta QRect
QVariant::RectFQMetaType::QRectFa QRectF
QVariant::RegExpQMetaType::QRegExpa QRegExp
QVariant::RegularExpressionQMetaType::QRegularExpressiona QRegularExpression
QVariant::RegionQMetaType::QRegiona QRegion
QVariant::SizeQMetaType::QSizea QSize
QVariant::SizeFQMetaType::QSizeFa QSizeF
QVariant::SizePolicyQMetaType::QSizePolicya QSizePolicy
QVariant::StringQMetaType::QStringa QString
QVariant::StringListQMetaType::QStringLista QStringList
QVariant::TextFormatQMetaType::QTextFormata QTextFormat
QVariant::TextLengthQMetaType::QTextLengtha QTextLength
QVariant::TimeQMetaType::QTimea QTime
QVariant::UIntQMetaType::UInta uint
QVariant::ULongLongQMetaType::ULongLonga qulonglong
QVariant::UrlQMetaType::QUrla QUrl
QVariant::Vector2DQMetaType::QVector2Da QVector2D
QVariant::Vector3DQMetaType::QVector3Da QVector3D
QVariant::Vector4DQMetaType::QVector4Da QVector4D
QVariant::UserTypeQMetaType::UserBase value for user-defined types.

Member Function Documentation

bool QVariant::operator<(const QVariant &v) const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Compares this QVariant with v and returns true if this is less than v.

Note: Comparability might not be availabe for the type stored in this QVariant or in v.

Warning: To make this function work with a custom type registered with qRegisterMetaType(), its comparison operator must be registered using QMetaType::registerComparators().

This operator is deprecated as it cannot establish a total order required for most use of this operator, which is the reason you cannot use QVariant as the key of a QMap.

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

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Compares this QVariant with v and returns true if this is less or equal than v.

Note: Comparability might not be available for the type stored in this QVariant or in v.

Warning: To make this function work with a custom type registered with qRegisterMetaType(), its comparison operator must be registered using QMetaType::registerComparators().

This operator is deprecated as it cannot establish a total order.

bool QVariant::operator>(const QVariant &v) const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Compares this QVariant with v and returns true if this is larger than v.

Note: Comparability might not be available for the type stored in this QVariant or in v.

Warning: To make this function work with a custom type registered with qRegisterMetaType(), its comparison operator must be registered using QMetaType::registerComparators().

This operator is deprecated as it cannot establish a total order.

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

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Compares this QVariant with v and returns true if this is larger or equal than v.

Note: Comparability might not be available for the type stored in this QVariant or in v.

Warning: To make this function work with a custom type registered with qRegisterMetaType(), its comparison operator must be registered using QMetaType::registerComparators().

This operator is deprecated as it cannot establish a total order.

Related Non-Members

template <typename T> bool qVariantCanConvert(const QVariant &value)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns true if the given value can be converted to the template type specified; otherwise returns false.

This function is equivalent to QVariant::canConvert(value).

Note: This function was provided as a workaround for MSVC 6 which did not support member template functions. It is advised to use the other form in new code.

See also QVariant::canConvert().

template <typename T> QVariant qVariantFromValue(const T &value)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns a variant containing a copy of the given value with template type T.

This function is equivalent to QVariant::fromValue(value).

Note: This function was provided as a workaround for MSVC 6 which did not support member template functions. It is advised to use the other form in new code.

For example, a QObject pointer can be stored in a variant with the following code:

 QObject *object = getObjectFromSomewhere();
 QVariant data = QVariant::fromValue(object);

See also QVariant::fromValue().

template <typename T> void qVariantSetValue(QVariant &variant, const T &value)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Sets the contents of the given variant to a copy of the value with the specified template type T.

This function is equivalent to QVariant::setValue(value).

Note: This function was provided as a workaround for MSVC 6 which did not support member template functions. It is advised to use the other form in new code.

See also QVariant::setValue().

template <typename T> T qVariantValue(const QVariant &value)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns the given value converted to the template type T.

This function is equivalent to QVariant::value<T>(value).

Note: This function was provided as a workaround for MSVC 6 which did not support member template functions. It is advised to use the other form in new code.

See also QVariant::value() and qvariant_cast().