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 Functions
(obsolete) bool | canConvert(int targetTypeId) const |
(obsolete) bool | convert(int targetTypeId) |
Static Public Members
(obsolete) QVariant::Type | nameToType(const char *name) |
(obsolete) const char * | typeToName(int typeId) |
Member Function Documentation
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
.
[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.