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.

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)

Related Non-Members

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

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

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

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

© 2019 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.