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) | QVariant(QVariant::Type type) |
(obsolete) bool | canConvert(int targetTypeId) const |
(obsolete) bool | convert(int targetTypeId) |
(obsolete) QVariant::Type | type() const |
Static Public Members
(obsolete) QVariant::Type | nameToType(const char *name) |
(obsolete) const char * | typeToName(int typeId) |
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.
Constant | Value | Description |
---|---|---|
QVariant::Invalid | QMetaType::UnknownType | no type |
QVariant::BitArray | QMetaType::QBitArray | a QBitArray |
QVariant::Bitmap | QMetaType::QBitmap | a QBitmap |
QVariant::Bool | QMetaType::Bool | a bool |
QVariant::Brush | QMetaType::QBrush | a QBrush |
QVariant::ByteArray | QMetaType::QByteArray | a QByteArray |
QVariant::Char | QMetaType::QChar | a QChar |
QVariant::Color | QMetaType::QColor | a QColor |
QVariant::Cursor | QMetaType::QCursor | a QCursor |
QVariant::Date | QMetaType::QDate | a QDate |
QVariant::DateTime | QMetaType::QDateTime | a QDateTime |
QVariant::Double | QMetaType::Double | a double |
QVariant::EasingCurve | QMetaType::QEasingCurve | a QEasingCurve |
QVariant::Uuid | QMetaType::QUuid | a QUuid |
QVariant::ModelIndex | QMetaType::QModelIndex | a QModelIndex |
QVariant::PersistentModelIndex | QMetaType::QPersistentModelIndex | a QPersistentModelIndex (since 5.5) |
QVariant::Font | QMetaType::QFont | a QFont |
QVariant::Hash | QMetaType::QVariantHash | a QVariantHash |
QVariant::Icon | QMetaType::QIcon | a QIcon |
QVariant::Image | QMetaType::QImage | a QImage |
QVariant::Int | QMetaType::Int | an int |
QVariant::KeySequence | QMetaType::QKeySequence | a QKeySequence |
QVariant::Line | QMetaType::QLine | a QLine |
QVariant::LineF | QMetaType::QLineF | a QLineF |
QVariant::List | QMetaType::QVariantList | a QVariantList |
QVariant::Locale | QMetaType::QLocale | a QLocale |
QVariant::LongLong | QMetaType::LongLong | a qlonglong |
QVariant::Map | QMetaType::QVariantMap | a QVariantMap |
QVariant::Transform | QMetaType::QTransform | a QTransform |
QVariant::Matrix4x4 | QMetaType::QMatrix4x4 | a QMatrix4x4 |
QVariant::Palette | QMetaType::QPalette | a QPalette |
QVariant::Pen | QMetaType::QPen | a QPen |
QVariant::Pixmap | QMetaType::QPixmap | a QPixmap |
QVariant::Point | QMetaType::QPoint | a QPoint |
QVariant::PointF | QMetaType::QPointF | a QPointF |
QVariant::Polygon | QMetaType::QPolygon | a QPolygon |
QVariant::PolygonF | QMetaType::QPolygonF | a QPolygonF |
QVariant::Quaternion | QMetaType::QQuaternion | a QQuaternion |
QVariant::Rect | QMetaType::QRect | a QRect |
QVariant::RectF | QMetaType::QRectF | a QRectF |
QVariant::RegularExpression | QMetaType::QRegularExpression | a QRegularExpression |
QVariant::Region | QMetaType::QRegion | a QRegion |
QVariant::Size | QMetaType::QSize | a QSize |
QVariant::SizeF | QMetaType::QSizeF | a QSizeF |
QVariant::SizePolicy | QMetaType::QSizePolicy | a QSizePolicy |
QVariant::String | QMetaType::QString | a QString |
QVariant::StringList | QMetaType::QStringList | a QStringList |
QVariant::TextFormat | QMetaType::QTextFormat | a QTextFormat |
QVariant::TextLength | QMetaType::QTextLength | a QTextLength |
QVariant::Time | QMetaType::QTime | a QTime |
QVariant::UInt | QMetaType::UInt | a uint |
QVariant::ULongLong | QMetaType::ULongLong | a qulonglong |
QVariant::Url | QMetaType::QUrl | a QUrl |
QVariant::Vector2D | QMetaType::QVector2D | a QVector2D |
QVariant::Vector3D | QMetaType::QVector3D | a QVector3D |
QVariant::Vector4D | QMetaType::QVector4D | a QVector4D |
QVariant::UserType | QMetaType::User | Base value for user-defined types. |
Member Function Documentation
QVariant::QVariant(QVariant::Type type)
This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Constructs an uninitialized variant of type type. This will create a variant in a special null state that if accessed will return a default constructed value of the type.
See also isNull().
bool QVariant::canConvert(int targetTypeId) const
This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
This is an overloaded function.
See also QMetaType::canConvert().
bool QVariant::convert(int targetTypeId)
This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Casts the variant to the requested type, targetTypeId. If the cast cannot be done, the variant is still changed to the requested type, but is left in a cleared null state similar to that constructed by QVariant(Type).
Returns true
if the current type of the variant was successfully cast; otherwise returns false
.
A QVariant containing a pointer to a type derived from QObject will also convert and return true for this function if a qobject_cast to the type described by targetTypeId would succeed. Note that this only works for QObject subclasses which use the Q_OBJECT macro.
Note: converting QVariants that are null due to not being initialized or having failed a previous conversion will always fail, changing the type, remaining null, and returning false
.
See also canConvert(int targetTypeId) and clear().
[static]
QVariant::Type QVariant::nameToType(const char *name)
This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Use QMetaType instead
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
.
QVariant::Type QVariant::type() const
This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Returns the storage type of the value stored in the variant. Although this function is declared as returning QVariant::Type, the return value should be interpreted as QMetaType::Type. In particular, QVariant::UserType is returned here only if the value is equal or greater than QMetaType::User.
Note that return values in the ranges QVariant::Char through QVariant::RegExp and QVariant::Font through QVariant::Transform correspond to the values in the ranges QMetaType::QChar through QMetaType::QRegularExpression and QMetaType::QFont through QMetaType::QQuaternion.
Pay particular attention when working with char and QChar variants. Note that there is no QVariant constructor specifically for type char, but there is one for QChar. For a variant of type QChar, this function returns QVariant::Char, which is the same as QMetaType::QChar, but for a variant of type char
, this function returns QMetaType::Char, which is not the same as QVariant::Char.
Also note that the types void*
, long
, short
, unsigned
long
, unsigned
short
, unsigned
char
, float
, QObject*
, and QWidget*
are represented in QMetaType::Type but not in QVariant::Type, and they can be returned by this function. However, they are considered to be user defined types when tested against QVariant::Type.
To test whether an instance of QVariant contains a data type that is compatible with the data type you are interested in, use canConvert().
See also userType() and metaType().
[static]
const char *QVariant::typeToName(int typeId)
This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Use QMetaType instead
Converts the int representation of the storage type, typeId, to its string representation.
Returns nullptr
if the type is QMetaType::UnknownType or doesn't exist.
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.