![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtCore More...
#include <qvariant.h>
Classes | |
struct | Private |
struct | PrivateShared |
Public Types | |
typedef Private | DataPtr |
Public Member Functions | |
QVariant () noexcept | |
Constructs an invalid variant. | |
~QVariant () | |
Destroys the QVariant and the contained object. | |
QVariant (QMetaType type, const void *copy=nullptr) | |
Constructs variant of type type, and initializes with copy if copy is not \nullptr. | |
QVariant (const QVariant &other) | |
Constructs a copy of the variant, p, passed as the argument to this constructor. | |
template<typename T , typename... Args, if_constructible< T, Args... > = true> | |
QVariant (std::in_place_type_t< T >, Args &&... args) noexcept(is_noexcept_constructible< q20::remove_cvref_t< T >, Args... >::value) | |
template<typename T , typename U , typename... Args, if_constructible< T, std::initializer_list< U > &, Args... > = true> | |
QVariant (std::in_place_type_t< T >, std::initializer_list< U > il, Args &&... args) noexcept(is_noexcept_constructible< q20::remove_cvref_t< T >, std::initializer_list< U > &, Args... >::value) | |
QVariant (int i) noexcept | |
Constructs a new variant with an integer value, val. | |
QVariant (uint ui) noexcept | |
Constructs a new variant with an unsigned integer value, val. | |
QVariant (qlonglong ll) noexcept | |
Constructs a new variant with a long long integer value, val. | |
QVariant (qulonglong ull) noexcept | |
Constructs a new variant with an unsigned long long integer value, val. | |
QVariant (bool b) noexcept | |
Constructs a new variant with a boolean value, val. | |
QVariant (double d) noexcept | |
Constructs a new variant with a floating point value, val. | |
QVariant (float f) noexcept | |
Constructs a new variant with a floating point value, val. | |
QVariant (QChar qchar) noexcept | |
Constructs a new variant with a char value, c. | |
QVariant (QDate date) noexcept | |
Constructs a new variant with a date value, val. | |
QVariant (QTime time) noexcept | |
Constructs a new variant with a time value, val. | |
QVariant (const QBitArray &bitarray) noexcept | |
Constructs a new variant with a bitarray value, val. | |
QVariant (const QByteArray &bytearray) noexcept | |
Constructs a new variant with a bytearray value, val. | |
QVariant (const QDateTime &datetime) noexcept | |
Constructs a new variant with a date/time value, val. | |
QVariant (const QHash< QString, QVariant > &hash) noexcept | |
Constructs a new variant with a hash of \l {QVariant}s, val. | |
QVariant (const QJsonArray &jsonArray) noexcept | |
QVariant (const QJsonObject &jsonObject) noexcept | |
QVariant (const QList< QVariant > &list) noexcept | |
Constructs a new variant with a list value, val. | |
QVariant (const QLocale &locale) noexcept | |
Constructs a new variant with a locale value, l. | |
QVariant (const QMap< QString, QVariant > &map) noexcept | |
Constructs a new variant with a map of \l {QVariant}s, val. | |
QVariant (const QRegularExpression &re) noexcept | |
QVariant (const QString &string) noexcept | |
Constructs a new variant with a string value, val. | |
QVariant (const QStringList &stringlist) noexcept | |
Constructs a new variant with a string list value, val. | |
QVariant (const QUrl &url) noexcept | |
Constructs a new variant with a url value of val. | |
QVariant (const QJsonValue &jsonValue) noexcept(Private::FitsInInternalSize< sizeof(CborValueStandIn)>) | |
QVariant (const QModelIndex &modelIndex) noexcept(Private::FitsInInternalSize< 8+2 *sizeof(quintptr)>) | |
QVariant (QUuid uuid) noexcept(Private::FitsInInternalSize< 16 >) | |
QVariant (QSize size) noexcept | |
Constructs a new variant with a size value of val. | |
QVariant (QSizeF size) noexcept(Private::FitsInInternalSize< sizeof(qreal) *2 >) | |
Constructs a new variant with a size value of val. | |
QVariant (QPoint pt) noexcept | |
Constructs a new variant with a point value of val. | |
QVariant (QPointF pt) noexcept(Private::FitsInInternalSize< sizeof(qreal) *2 >) | |
Constructs a new variant with a point value of val. | |
QVariant (QLine line) noexcept(Private::FitsInInternalSize< sizeof(int) *4 >) | |
Constructs a new variant with a line value of val. | |
QVariant (QLineF line) noexcept(Private::FitsInInternalSize< sizeof(qreal) *4 >) | |
Constructs a new variant with a line value of val. | |
QVariant (QRect rect) noexcept(Private::FitsInInternalSize< sizeof(int) *4 >) | |
Constructs a new variant with a rect value of val. | |
QVariant (QRectF rect) noexcept(Private::FitsInInternalSize< sizeof(qreal) *4 >) | |
Constructs a new variant with a rect value of val. | |
QVariant (const QEasingCurve &easing) noexcept(false) | |
QVariant (const QJsonDocument &jsonDocument) noexcept(false) | |
QVariant (const QPersistentModelIndex &modelIndex) noexcept(false) | |
QT_ASCII_CAST_WARN | QVariant (const char *str) noexcept(false) |
Constructs a new variant with a string value of val. | |
QVariant (QLatin1StringView string) noexcept(false) | |
Constructs a new variant with a QString value from the Latin-1 string viewed by val. | |
template<typename T , std::enable_if_t< std::disjunction_v< std::is_pointer< T >, std::is_member_pointer< T > >, bool > = false> | |
QVariant (T)=delete | |
QVariant & | operator= (const QVariant &other) |
Move-assigns other to this QVariant instance. | |
QVariant (QVariant &&other) noexcept | |
Move-constructs a QVariant instance, making it point at the same object that other was pointing to. | |
void | swap (QVariant &other) noexcept |
int | userType () const |
int | typeId () const |
Returns the storage type of the value stored in the variant. | |
const char * | typeName () const |
Returns the name of the type stored in the variant. | |
QMetaType | metaType () const |
bool | canConvert (QMetaType targetType) const |
bool | convert (QMetaType type) |
Casts the variant to the requested type, targetType. | |
bool | canView (QMetaType targetType) const |
bool | isValid () const |
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns false . | |
bool | isNull () const |
Returns true if this is a null variant, false otherwise. | |
void | clear () |
Convert this variant to type QMetaType::UnknownType and free up any resources used. | |
void | detach () |
bool | isDetached () const |
int | toInt (bool *ok=nullptr) const |
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; otherwise returns 0. | |
uint | toUInt (bool *ok=nullptr) const |
Returns the variant as an unsigned int if the variant has userType() \l QMetaType::UInt, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, or \l QMetaType::ULongLong; otherwise returns 0. | |
qlonglong | toLongLong (bool *ok=nullptr) const |
Returns the variant as a long long int if the variant has userType() \l QMetaType::LongLong, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; otherwise returns 0. | |
qulonglong | toULongLong (bool *ok=nullptr) const |
Returns the variant as an unsigned long long int if the variant has type() \l QMetaType::ULongLong, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, or \l QMetaType::UInt; otherwise returns 0. | |
bool | toBool () const |
Returns the variant as a bool if the variant has userType() Bool. | |
double | toDouble (bool *ok=nullptr) const |
Returns the variant as a double if the variant has userType() \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; otherwise returns 0.0. | |
float | toFloat (bool *ok=nullptr) const |
Returns the variant as a float if the variant has userType() \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; otherwise returns 0.0. | |
qreal | toReal (bool *ok=nullptr) const |
Returns the variant as a qreal if the variant has userType() \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; otherwise returns 0.0. | |
QByteArray | toByteArray () const |
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMetaType::QString (converted using QString::fromUtf8()); otherwise returns an empty byte array. | |
QBitArray | toBitArray () const |
Returns the variant as a QBitArray if the variant has userType() \l QMetaType::QBitArray; otherwise returns an empty bit array. | |
QString | toString () const |
Returns the variant as a QString if the variant has a userType() including, but not limited to: | |
QStringList | toStringList () const |
Returns the variant as a QStringList if the variant has userType() \l QMetaType::QStringList, \l QMetaType::QString, or \l QMetaType::QVariantList of a type that can be converted to QString; otherwise returns an empty list. | |
QChar | toChar () const |
Returns the variant as a QChar if the variant has userType() \l QMetaType::QChar, \l QMetaType::Int, or \l QMetaType::UInt; otherwise returns an invalid QChar. | |
QDate | toDate () const |
Returns the variant as a QDate if the variant has userType() \l QMetaType::QDate, \l QMetaType::QDateTime, or \l QMetaType::QString; otherwise returns an invalid date. | |
QTime | toTime () const |
Returns the variant as a QTime if the variant has userType() \l QMetaType::QTime, \l QMetaType::QDateTime, or \l QMetaType::QString; otherwise returns an invalid time. | |
QDateTime | toDateTime () const |
Returns the variant as a QDateTime if the variant has userType() \l QMetaType::QDateTime, \l QMetaType::QDate, or \l QMetaType::QString; otherwise returns an invalid date/time. | |
QList< QVariant > | toList () const |
Returns the variant as a QVariantList if the variant has userType() \l QMetaType::QVariantList. | |
QMap< QString, QVariant > | toMap () const |
Returns the variant as a QVariantMap if the variant has type() \l QMetaType::QVariantMap. | |
QHash< QString, QVariant > | toHash () const |
Returns the variant as a QHash<QString, QVariant> if the variant has type() \l QMetaType::QVariantHash; otherwise returns an empty map. | |
QPoint | toPoint () const |
Returns the variant as a QPoint if the variant has userType() \l QMetaType::QPoint or \l QMetaType::QPointF; otherwise returns a null QPoint. | |
QPointF | toPointF () const |
Returns the variant as a QPointF if the variant has userType() \l QMetaType::QPoint or \l QMetaType::QPointF; otherwise returns a null QPointF. | |
QRect | toRect () const |
Returns the variant as a QRect if the variant has userType() \l QMetaType::QRect; otherwise returns an invalid QRect. | |
QSize | toSize () const |
Returns the variant as a QSize if the variant has userType() \l QMetaType::QSize; otherwise returns an invalid QSize. | |
QSizeF | toSizeF () const |
Returns the variant as a QSizeF if the variant has userType() \l QMetaType::QSizeF; otherwise returns an invalid QSizeF. | |
QLine | toLine () const |
Returns the variant as a QLine if the variant has userType() \l QMetaType::QLine; otherwise returns an invalid QLine. | |
QLineF | toLineF () const |
Returns the variant as a QLineF if the variant has userType() \l QMetaType::QLineF; otherwise returns an invalid QLineF. | |
QRectF | toRectF () const |
Returns the variant as a QRectF if the variant has userType() \l QMetaType::QRect or \l QMetaType::QRectF; otherwise returns an invalid QRectF. | |
QLocale | toLocale () const |
Returns the variant as a QLocale if the variant has userType() \l QMetaType::QLocale; otherwise returns an invalid QLocale. | |
QUuid | toUuid () const |
QUrl | toUrl () const |
Returns the variant as a QUrl if the variant has userType() \l QMetaType::QUrl; otherwise returns an invalid QUrl. | |
QJsonValue | toJsonValue () const |
QJsonObject | toJsonObject () const |
QJsonArray | toJsonArray () const |
QJsonDocument | toJsonDocument () const |
void | load (QDataStream &ds) |
Internal function for loading a variant from stream s. | |
void | save (QDataStream &ds) const |
Internal function for saving a variant to the stream s. | |
void * | data () |
Returns a pointer to the contained object as a generic void* that can be written to. | |
const void * | constData () const |
const void * | data () const |
Returns a pointer to the contained object as a generic void* that cannot be written to. | |
template<typename T , typename... Args, if_constructible< T, Args... > = true> | |
T & | emplace (Args &&... args) |
template<typename T , typename U , typename... Args, if_constructible< T, std::initializer_list< U > &, Args... > = true> | |
T & | emplace (std::initializer_list< U > list, Args &&... args) |
template<typename T , typename = std::enable_if_t<!std::is_same_v<std::decay_t<T>, QVariant>>> | |
void | setValue (T &&avalue) |
Stores a copy of value. | |
void | setValue (const QVariant &avalue) |
Copies value over this QVariant. | |
void | setValue (QVariant &&avalue) |
Moves value over this QVariant. | |
template<typename T > | |
T | value () const & |
template<typename T > | |
T | view () |
Returns a mutable view of template type {T} on the stored value. | |
template<typename T > | |
T | value () && |
template<typename T > | |
bool | canConvert () const |
Returns true if the variant can be converted to the template type {T}, otherwise false. | |
template<typename T > | |
bool | canView () const |
Returns true if a mutable view of the template type {T} can be created on this variant, otherwise false . | |
DataPtr & | data_ptr () |
const DataPtr & | data_ptr () const |
Static Public Member Functions | |
template<typename T , if_rvalue< T > = true> | |
static auto | fromValue (T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant > |
template<typename T > | |
static auto | fromValue (const T &value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::is_copy_constructible_v< T > &&std::is_destructible_v< T >, QVariant > |
Returns a QVariant containing a copy of value. | |
template<typename... Types> | |
static QVariant | fromStdVariant (const std::variant< Types... > &value) |
template<typename... Types> | |
static QVariant | fromStdVariant (std::variant< Types... > &&value) |
static QPartialOrdering | compare (const QVariant &lhs, const QVariant &rhs) |
Compares the objects at lhs and rhs for ordering. | |
Protected Member Functions | |
void | create (int type, const void *copy) |
void | create (QMetaType type, const void *copy) |
bool | equals (const QVariant &other) const |
bool | convert (int type, void *ptr) const |
bool | view (int type, void *ptr) |
Protected Attributes | |
Private | d |
Friends | |
bool | operator== (const QVariant &a, const QVariant &b) |
Returns true if v1 and v2 are equal; otherwise returns false . | |
bool | operator!= (const QVariant &a, const QVariant &b) |
Returns false if v1 and v2 are equal; otherwise returns true . | |
template<typename T > | |
auto | operator<< (const QDebug &debug, const T &variant) -> std::enable_if_t< std::is_same_v< T, QVariant >, QDebug > |
template<typename T > | |
T * | get_if (QVariant *v) noexcept |
If v contains an object of type T , returns a pointer to the contained object, otherwise returns \nullptr. | |
template<typename T > | |
const T * | get_if (const QVariant *v) noexcept |
template<typename T > | |
T | qvariant_cast (const QVariant &) |
Returns the given value converted to the template type {T}. | |
template<typename T > | |
T | qvariant_cast (QVariant &&) |
Related Symbols | |
(Note that these are not member symbols.) | |
QDataStream & | operator>> (QDataStream &s, QVariant &p) |
QDataStream & | operator<< (QDataStream &s, const QVariant &p) |
Writes a variant p to the stream s. | |
QDataStream & | operator>> (QDataStream &s, QVariant::Type &p) |
QDataStream & | operator<< (QDataStream &s, const QVariant::Type p) |
template< typename T > T | qvariant_cast (const QVariant &value) |
Returns the given value converted to the template type {T}. | |
template< typename T > T | qVariantValue (const QVariant &value) |
bool | qVariantCanConvert (const QVariant &value) |
QVariantList | |
Synonym for QList<QVariant>. | |
QVariantMap | |
Synonym for QMap<QString, QVariant>. | |
QVariantHash | |
\inmodule QtCore
The QVariant class acts like a union for the most common Qt data types.
Because C++ forbids unions from including types that have non-default constructors or destructors, most interesting Qt classes cannot be used in unions. Without QVariant, this would be a problem for QObject::property() and for database work, etc.
A QVariant object holds a single value of a single typeId() at a time. (Some types are multi-valued, for example a string list.) You can find out what type, T, the variant holds, convert it to a different type using convert(), get its value using one of the toT() functions (e.g., toSize()), and check whether the type can be converted to a particular type using canConvert().
The methods named toT() (e.g., toInt(), toString()) are const. If you ask for the stored type, they return a copy of the stored object. If you ask for a type that can be generated from the stored type, toT() copies and converts and leaves the object itself unchanged. If you ask for a type that cannot be generated from the stored type, the result depends on the type; see the function documentation for details.
Here is some example code to demonstrate the use of QVariant:
You can even store QList<QVariant> and QMap<QString, QVariant> values in a variant, so you can easily construct arbitrarily complex data structures of arbitrary types. This is very powerful and versatile, but may prove less memory and speed efficient than storing specific types in standard data structures.
QVariant also supports the notion of null values. A variant is null if the variant contains no initialized value, or contains a null pointer.
QVariant can be extended to support other types than those mentioned in the \l QMetaType::Type enum. See \l{Creating Custom Qt Types}{Creating Custom Qt Types} for details.
Definition at line 63 of file qvariant.h.
Definition at line 702 of file qvariant.h.
|
inlinenoexcept |
Constructs an invalid variant.
Definition at line 217 of file qvariant.h.
Referenced by QVariant::Private::Private(), create(), and save().
QVariant::~QVariant | ( | ) |
Destroys the QVariant and the contained object.
Definition at line 544 of file qvariant.cpp.
References d, QVariant::Private::data, and QVariant::Private::is_shared.
Referenced by QQmlBindEntryContent::destroy(), and QV4::Moth::VME::exec().
Constructs variant of type type, and initializes with copy if copy is not \nullptr.
Note that you have to pass the address of the variable you want stored.
Usually, you never have to use this constructor, use QVariant::fromValue() instead to construct variants from the pointer types represented by QMetaType::VoidStar
, and QMetaType::QObjectStar
.
If type does not support copy and default construction, the variant will be invalid.
Definition at line 943 of file qvariant.cpp.
QVariant::QVariant | ( | const QVariant & | other | ) |
Constructs a copy of the variant, p, passed as the argument to this constructor.
Definition at line 557 of file qvariant.cpp.
|
inlineexplicitnoexcept |
Definition at line 232 of file qvariant.h.
References args.
|
inlineexplicitnoexcept |
Definition at line 242 of file qvariant.h.
References args.
|
noexcept |
Constructs a new variant with an integer value, val.
Definition at line 952 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with an unsigned integer value, val.
Definition at line 953 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a long long integer value, val.
Definition at line 954 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with an unsigned long long integer value, val.
Definition at line 955 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a boolean value, val.
Definition at line 956 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a floating point value, val.
Definition at line 957 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a floating point value, val.
Definition at line 958 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a char value, c.
Definition at line 963 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a date value, val.
Definition at line 966 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a time value, val.
Definition at line 967 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a bitarray value, val.
Definition at line 961 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a bytearray value, val.
Definition at line 960 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a date/time value, val.
Definition at line 968 of file qvariant.cpp.
Constructs a new variant with a hash of \l {QVariant}s, val.
Definition at line 972 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a json array value, val.
Definition at line 1010 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a json object value, val.
Definition at line 1009 of file qvariant.cpp.
Constructs a new variant with a list value, val.
Definition at line 970 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a locale value, l.
Definition at line 1000 of file qvariant.cpp.
Constructs a new variant with a map of \l {QVariant}s, val.
Definition at line 971 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with the regular expression value re.
|
noexcept |
Constructs a new variant with a string value, val.
Definition at line 962 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a string list value, val.
Definition at line 964 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a url value of val.
Definition at line 998 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a json value, val.
Definition at line 1006 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a QModelIndex value, val.
|
noexcept |
Constructs a new variant with an uuid value, val.
Definition at line 1004 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a size value of val.
Definition at line 992 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a size value of val.
Definition at line 994 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a point value of val.
Definition at line 980 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a point value of val.
Definition at line 982 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a line value of val.
Definition at line 988 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a line value of val.
Definition at line 990 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a rect value of val.
Definition at line 984 of file qvariant.cpp.
|
noexcept |
Constructs a new variant with a rect value of val.
Definition at line 986 of file qvariant.cpp.
QVariant::QVariant | ( | const QEasingCurve & | val | ) |
Constructs a new variant with an easing curve value, val.
QVariant::QVariant | ( | const QJsonDocument & | val | ) |
Constructs a new variant with a json document value, val.
Definition at line 1011 of file qvariant.cpp.
QVariant::QVariant | ( | const QPersistentModelIndex & | val | ) |
Constructs a new variant with a QPersistentModelIndex value, val.
|
inline |
Constructs a new variant with a string value of val.
The variant creates a deep copy of val into a QString assuming UTF-8 encoding on the input val.
Note that val is converted to a QString for storing in the variant and QVariant::userType() will return QMetaType::QString for the variant.
You can disable this operator by defining QT_NO_CAST_FROM_ASCII
when you compile your applications.
Definition at line 302 of file qvariant.h.
QVariant::QVariant | ( | QLatin1StringView | string | ) |
Constructs a new variant with a QString value from the Latin-1 string viewed by val.
Definition at line 974 of file qvariant.cpp.
|
delete |
|
inlinenoexcept |
Move-constructs a QVariant instance, making it point at the same object that other was pointing to.
Definition at line 330 of file qvariant.h.
References other().
|
inline |
Returns true
if the variant can be converted to the template type {T}, otherwise false.
Example:
A QVariant containing a pointer to a type derived from QObject will also return true for this function if a qobject_cast to the template type {T} would succeed. Note that this only works for QObject subclasses which use the Q_OBJECT macro.
Definition at line 590 of file qvariant.h.
|
inline |
Returns true
if the variant's type can be cast to the requested type, type. Such casting is done automatically when calling the toInt(), toBool(), ... methods.
Definition at line 342 of file qvariant.h.
References QMetaType::canConvert(), and d.
Referenced by QQnxWindow::QQnxWindow(), QQnxWindow::QQnxWindow(), DarwinBluetooth::add_attribute(), DarwinBluetooth::add_attribute(), DarwinBluetooth::add_attribute(), DarwinBluetooth::add_attribute(), DarwinBluetooth::add_attribute< QBluetoothUuid >(), DarwinBluetooth::add_attribute< QBluetoothUuid >(), DarwinBluetooth::add_attribute< QString >(), DarwinBluetooth::add_attribute< QString >(), DarwinBluetooth::add_attribute< QUrl >(), DarwinBluetooth::add_attribute< QUrl >(), DarwinBluetooth::add_attribute< unsigned short >(), DarwinBluetooth::add_sequence_attribute(), DarwinBluetooth::add_sequence_attribute(), convert(), QAbstractItemModelTesterPrivate::data(), QuickTestResult::fuzzyCompare(), QHeaderView::initStyleOptionForIndex(), QQmlToolingSettings::isSet(), QAbstractItemView::keyPressEvent(), QWindowsMenuBar::menuBarOf(), QV4::VariantPrototype::method_toString(), QHeaderView::paintEvent(), QHeaderView::sectionSizeFromContents(), QQuickShaderEffectPrivate::setMesh(), QHeaderViewPrivate::setupSectionIndicator(), QTestPrivate::testDataGuiRoles(), and QQuickFileDialogImplPrivate::updateSelectedFile().
|
inline |
Returns true
if a mutable view of the template type {T} can be created on this variant, otherwise
false
.
Definition at line 594 of file qvariant.h.
|
inline |
Definition at line 346 of file qvariant.h.
References QMetaType::canView(), and d.
void QVariant::clear | ( | ) |
Convert this variant to type QMetaType::UnknownType and free up any resources used.
Definition at line 1136 of file qvariant.cpp.
References d, QVariant::Private::data, and QVariant::Private::is_shared.
Referenced by QPlaceSearchRequestPrivate::clear(), QAbstractSpinBoxPrivate::clearCache(), convert(), load(), operator=(), and QDateTimeEditPrivate::validateAndInterpret().
|
static |
Compares the objects at lhs and rhs for ordering.
Returns QPartialOrdering::Unordered if comparison is not supported or the values are unordered. Otherwise, returns QPartialOrdering::Less, QPartialOrdering::Equivalent or QPartialOrdering::Greater if lhs is less than, equivalent to or greater than rhs, respectively.
If the variants contain data with a different metatype, the values are considered unordered unless they are both of numeric or pointer types, where regular numeric or pointer comparison rules will be used.
If both variants contain data of the same metatype, the method will use the QMetaType::compare method to determine the ordering of the two variants, which can also indicate that it can't establish an ordering between the two values.
Definition at line 2452 of file qvariant.cpp.
References canBeNumericallyCompared(), constData(), d, QMetaType::iface(), metaType(), numericCompare(), pointerCompare(), qvCanConvertMetaObject(), QVariant::Private::type(), and QPartialOrdering::Unordered.
Referenced by QAuthenticatorPrivate::parseHttpResponse().
|
inline |
Definition at line 446 of file qvariant.h.
References d.
Referenced by QQmlListReference::QQmlListReference(), QSSGRhiShaderPipeline::addStage(), addStartCond(), QQmlJS::Dom::SimpleObjectWrapT< T >::asT(), QQmlListAccessor::at(), QSSGStageGeneratorBase::buildShaderSourcePass2(), compare(), QtPrivate::QVariantTypeCoercer::convert(), convert(), convert(), QV4::convertAndDo(), QQmlListAccessor::count(), data(), detach(), QV4::ExecutionEngine::fromVariant(), QV4::ExecutionEngine::fromVariant(), QVariantAnimation::interpolated(), QSqlResultPrivate::isVariantNull(), load(), QQmlVMEMetaObject::metaCall(), QV4::ExecutionEngine::metaTypeFromJS(), QSGMaterialShaderPrivate::prepare(), QTest::qExec(), qQmlTranslationPropertyBindingCreateBinding(), qtObjectFromJS(), QRhiGles2::registerUniformIfActive(), save(), QQmlListAccessor::set(), QWizard::setField(), QQmlListAccessor::setList(), QQmlAdaptorModel::setModel(), QQuickAnimationPropertyUpdater::setValue(), QV4::Heap::Sequence::setVariant(), QtSharedPointer::sharedPointerFromVariant_internal(), toBool(), toVariant(), QV4::SequencePrototype::toVariant(), QtSharedPointer::weakPointerFromVariant_internal(), and QQmlPropertyPrivate::write().
|
protected |
Created for qvariant_cast() usage
Definition at line 2153 of file qvariant.cpp.
References constData(), QMetaType::convert(), d, ptr(), and QVariant::Private::type().
bool QVariant::convert | ( | QMetaType | targetType | ) |
Casts the variant to the requested type, targetType.
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 targetType would succeed. Note that this only works for QObject subclasses which use the Q_OBJECT macro.
false
.Definition at line 2127 of file qvariant.cpp.
References canConvert(), clear(), constData(), QMetaType::convert(), create(), d, QMetaType::id(), QVariant::Private::is_null, QMetaType::isValid(), ok, and QVariant::Private::type().
Referenced by QtPrivate::QVariantTypeCoercer::convert(), QV4::convertAndDo(), QQuickPropertyAnimationPrivate::convertVariant(), qQmlTranslationPropertyBindingCreateBinding(), QMimeDataPrivate::retrieveTypedData(), QQmlListAccessor::set(), QQmlTableModel::setData(), toVariant(), QV4::SequencePrototype::toVariant(), and QQmlPropertyPrivate::write().
|
protected |
Constructs a variant private of type type, and initializes with copy if copy is not \nullptr.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 522 of file qvariant.cpp.
References copy(), and create().
Definition at line 533 of file qvariant.cpp.
References QVariant(), and copy().
void * QVariant::data | ( | ) |
Returns a pointer to the contained object as a generic void* that can be written to.
This function detaches the QVariant. When called on a \l{isNull}{null-QVariant}, the QVariant will not be null after the call.
Definition at line 2487 of file qvariant.cpp.
References constData(), d, detach(), and QVariant::Private::is_null.
Referenced by convertToIterable(), QVariant::PrivateShared::create(), QModelIndex::data(), QItemDelegatePrivate::displayRect(), doWriteProperties(), doWriteProperties(), doWriteProperties(), doWriteProperty(), QItemDelegate::drawBackground(), dumpAttributeVariant(), QItemDelegate::editorEvent(), QStyledItemDelegate::editorEvent(), QComboMenuDelegate::editorEvent(), QV4::Moth::VME::exec(), QOCICols::execBatch(), fromMatchingType(), fromMatchingType(), QSideBarDelegate::initStyleOption(), QQmlPrivate::loadFallbackAsVariant(), QQmlPrivate::loadObjectAsVariant(), QQmlVMEMetaObject::metaCall(), QV4::ExecutionEngine::metaTypeFromJS(), QQmlJS::Dom::SimpleObjectWrapT< T >::mutableAsT(), QItemDelegate::rect(), QQmlListAccessor::set(), QItemDelegate::setEditorData(), QStyledItemDelegate::setEditorData(), QQmlJS::Dom::setFormalParameterKind(), QItemDelegate::setOptions(), QItemDelegate::sizeHint(), QStyledItemDelegate::sizeHint(), QQmlPrivate::storeFallbackAsVariant(), QQmlPrivate::AOTCompiledContext::storeNameSloppy(), QQmlPrivate::storeObjectAsVariant(), toVariant(), tryConvertAndAssign(), VDMAbstractItemModelDataType::value(), and QQmlPropertyPrivate::write().
|
inline |
Returns a pointer to the contained object as a generic void* that cannot be written to.
Definition at line 448 of file qvariant.h.
|
inline |
Definition at line 703 of file qvariant.h.
References d.
Referenced by createVariantData().
|
inline |
Definition at line 704 of file qvariant.h.
References d.
void QVariant::detach | ( | ) |
Definition at line 1101 of file qvariant.cpp.
References constData(), d, QVariant::Private::data, QVariant::Private::is_shared, Q_ASSERT, and QVariant::Private::typeInterface().
Referenced by data().
|
inline |
{*this} with an object of type
{T}, constructed from {args}
{...}. If
{*this} was non-null, the previously held object is destroyed first. If possible, this method will reuse memory allocated by the QVariant. Returns a reference to the newly-created object. Definition at line 475 of file qvariant.h.
References args.
|
inline |
initializer_list
. It behaves otherwise equivalent to the non-initializer list overload. Definition at line 482 of file qvariant.h.
|
protected |
Definition at line 2407 of file qvariant.cpp.
References canBeNumericallyCompared(), d, QPartialOrdering::Equivalent, numericCompare(), pointerCompare(), qvCanConvertMetaObject(), QVariant::Private::storage(), and QVariant::Private::type().
|
inlinestatic |
Returns a QVariant with the type and value of the active variant of value. If the active type is std::monostate a default QVariant is returned.
Definition at line 578 of file qvariant.h.
|
inlinestatic |
Definition at line 584 of file qvariant.h.
|
inlinestaticnoexcept |
Returns a QVariant containing a copy of value.
Behaves exactly like setValue() otherwise.
Example:
Definition at line 561 of file qvariant.h.
|
inlinestaticnoexcept |
Definition at line 531 of file qvariant.h.
References QMetaType::registerType().
Referenced by QDBusMenuItem::QDBusMenuItem(), QQuickDayOfWeekRow::QQuickDayOfWeekRow(), QQuickMonthGrid::QQuickMonthGrid(), QQuickSimpleAction::QQuickSimpleAction(), QQuickTreeView::QQuickTreeView(), QQuickWeekNumberColumn::QQuickWeekNumberColumn(), QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine(), QQmlJS::Dom::SimpleObjectWrap::SimpleObjectWrap(), QFFmpegMetaData::addEntry(), addTagToMap(), QQuickColorProvider::alpha(), QSSGRuntimeUtils::applyPropertyValue(), QSSGCustomMaterialSystem::applyRhiShaderPropertyValues(), QQmlListAccessor::at(), QDeclarativeGeocodeModel::bounds(), cameraInterpolator(), QQmlTableModel::clear(), QJSEngine::coerceValue(), QtObject::color(), colorVariantFromJSValue(), OrgBluezDevice1Interface::ConnectProfile(), QQuickContainer::contentModel(), QQuickMenu::contentModel(), QQmlContext::contextProperty(), cppQmlInterface(), QQmlPrivate::ValueType< T, F, true, false >::create(), QIBusProxy::CreateInputContext(), QIBusProxyPortal::CreateInputContext(), QNetworkAccessManager::createRequest(), QLocale::createSeparatedList(), QQuickColorProvider::darker(), QDeclarativeGeocodeModel::data(), QDeclarativeGeoRouteModel::data(), QDeclarativePlaceContentModel::data(), QDeclarativeSupportedCategoriesModel::data(), QPdfLinkModel::data(), QDeclarativeSearchResultModel::data(), Cursor::data(), QMYSQLResult::data(), QQmlEngineDebugClient::decode(), QQuickPropertyChangesPrivate::decodeBinding(), QQmlBindPrivate::decodeBinding(), QPlatformTheme::defaultThemeHint(), OrgBluezDevice1Interface::DisconnectProfile(), QQuickItemGrabResultPrivate::ensureImageInCache(), QIOSMenu::eventFilter(), QIBusProxy::Exit(), DarwinBluetooth::extract_attribute_value(), QIBusPlatformInputContext::filterEvent(), findAttachedParent(), QQmlContextData::findObjectId(), OrgFreedesktopDBusPropertiesInterface::Get(), OrgFreedesktopDBusPropertiesInterface::GetAll(), QNetworkReplyImplPrivate::getDownloadBuffer(), QQuick3DSceneManager::getOrSetWindowAttachment(), QMimerSQLResult::handle(), QMimerSQLDriver::handle(), QMYSQLResult::handle(), QMYSQLDriver::handle(), QOCIResult::handle(), QOCIDriver::handle(), QPSQLResult::handle(), QPSQLDriver::handle(), QSQLiteResult::handle(), QSQLiteDriver::handle(), QGeoPolygon::hole(), QGeoJson::importGeoJson(), importGeometry(), importMultiLineString(), importMultiPoint(), importMultiPolygon(), QPrintDialogPrivate::init(), QQmlDelegateModelPartsMetaObject::initialValue(), QQuickTableViewPrivate::initItemCallback(), QQuickToolTipAttachedPrivate::instance(), QQuickTableViewPrivate::itemReusedCallback(), QOCIResult::lastInsertId(), QQuickColorProvider::lighter(), QBluetoothServer::listen(), macToQtFormat(), main(), main(), QQuickShaderEffectPrivate::mesh(), QV4::ExecutionEngine::metaTypeFromJS(), QQuickRepeater::model(), QQuick3DRepeater::model(), QQmlDMAbstractItemModelData::modelData(), QQuickHeaderViewBasePrivate::modelImpl(), VDMAbstractItemModelDataType::modelIndex(), OrgBluezProfile1Interface::NewConnection(), objectToVariant(), QNetworkReplyHttpImplPrivate::onRedirected(), QNetworkFile::open(), QDBusObjectPath::operator QVariant(), QBitmap::operator QVariant(), QIcon::operator QVariant(), QImage::operator QVariant(), QPixmap::operator QVariant(), QCursor::operator QVariant(), QKeySequence::operator QVariant(), QPalette::operator QVariant(), QMatrix4x4::operator QVariant(), QQuaternion::operator QVariant(), QVector2D::operator QVariant(), QVector3D::operator QVariant(), QVector4D::operator QVariant(), QBrush::operator QVariant(), QColor::operator QVariant(), QColorSpace::operator QVariant(), QPen::operator QVariant(), QPolygon::operator QVariant(), QPolygonF::operator QVariant(), QRegion::operator QVariant(), QTransform::operator QVariant(), QFont::operator QVariant(), QTextLength::operator QVariant(), QTextFormat::operator QVariant(), QSizePolicy::operator QVariant(), QDDSHandler::option(), QQuickOverlay::overlay(), VDMAbstractItemModelDataType::parentModelIndex(), parseCookieHeader(), parseEditorial(), parseHeaderValue(), parseImage(), parseReview(), QQuickPathPolyline::path(), QQuickPathMultiline::paths(), QIBusProxy::Ping(), QTipLabel::placeTip(), QIBusInputContextProxy::ProcessKeyEvent(), QtBluezPeripheralService::properties(), QIBusInputContextProxy::PropertyActivate(), DynamicRoleModelNodeMetaObject::propertyWritten(), proxyModelSetter(), q_coordinateEastInterpolator(), q_coordinateInterpolator(), q_coordinateShortestInterpolator(), q_coordinateWestInterpolator(), Q_LOGGING_CATEGORY(), q_quaternionInterpolator(), q_quaternionNlerpInterpolator(), qDBusPropertyGet(), qDBusPropertyGetAll(), QT_DECL_METATYPE_EXTERN_TAGGED(), QLocale::quoteString(), QQmlVMEMetaObject::readPropertyAsVariant(), OrgBluezGattCharacteristic1Interface::ReadValue(), OrgBluezGattDescriptor1Interface::ReadValue(), QQmlPropertyPrivate::readValueProperty(), OrgBluezLEAdvertisingManager1Interface::RegisterAdvertisement(), OrgBluezGattManager1Interface::RegisterApplication(), QIBusProxy::RegisterComponent(), OrgBluezProfileManager1Interface::RegisterProfile(), OrgBluezAdapter1Interface::RemoveDevice(), QSSGQmlUtilities::replaceReferencesToResource(), QNetworkReplyHttpImplPrivate::replyDownloadMetaData(), QQuickFolderBreadcrumbBarPrivate::repopulate(), OrgBluezProfile1Interface::RequestDisconnection(), QQnxClipboard::MimeData::retrieveData(), QQmlDelegateModel::rootIndex(), QScrollerProperties::scrollMetric(), QDeclarativeSearchModelBase::searchArea(), OrgFreedesktopDBusPropertiesInterface::Set(), QBluetoothServiceInfo::setAttribute(), QBluetoothServiceInfo::setAttribute(), QIBusInputContextProxy::SetCapabilities(), QQmlContext::setContextProperty(), QQuickTableViewPrivate::setCurrentOnDelegateItem(), QIBusInputContextProxy::SetCursorLocation(), QIBusInputContextProxy::SetCursorLocationRelative(), OrgBluezLEAdvertisement1Adaptor::setDiscoverable(), OrgBluezAdapter1Interface::SetDiscoveryFilter(), QNetworkReplyImplPrivate::setDownloadBuffer(), QIBusInputContextProxy::SetEngine(), QQuickGeoCoordinateAnimation::setFrom(), QQuick3DQuaternionAnimation::setFrom(), OrgBluezLEAdvertisement1Adaptor::setIncludes(), InstanceRepeater::setInstancing(), QQmlListAccessor::setList(), OrgBluezLEAdvertisement1Adaptor::setLocalName(), OrgBluezLEAdvertisement1Adaptor::setManufacturerData(), OrgBluezLEAdvertisement1Adaptor::setMaxInterval(), OrgBluezLEAdvertisement1Adaptor::setMinInterval(), setModelProperties(), QPrinterPagedPaintDevicePrivate::setPageLayout(), QPrinterPagedPaintDevicePrivate::setPageMargins(), QPrinterPagedPaintDevicePrivate::setPageSize(), OrgBluezAdapter1Interface::setPowered(), QMacPrintEngine::setProperty(), QWin32PrintEngine::setProperty(), QSSGSceneDesc::setProperty(), QSSGSceneDesc::setProperty(), QSSGSceneDesc::setProperty(), QSSGSceneDesc::setProperty(), QSSGSceneDesc::setProperty(), QSSGSceneDesc::setProperty(), QSSGSceneDesc::setProperty(), QSSGQmlUtilities::setProperty(), QQuickTableViewPrivate::setSelectedOnDelegateItem(), QBluetoothServiceInfo::setServiceAvailability(), QBluetoothServiceInfo::setServiceDescription(), QBluetoothServiceInfo::setServiceName(), QBluetoothServiceInfo::setServiceProvider(), OrgBluezLEAdvertisement1Adaptor::setServiceUUIDs(), QIBusInputContextProxy::SetSurroundingText(), QTreeWidgetItem::setTextAlignment(), QListWidgetItem::setTextAlignment(), QTableWidgetItem::setTextAlignment(), QStandardItem::setTextAlignment(), QQuickGeoCoordinateAnimation::setTo(), QQuick3DQuaternionAnimation::setTo(), OrgBluezDevice1Interface::setTrusted(), OrgBluezLEAdvertisement1Adaptor::setType(), QQmlBinding::slowWrite(), someFunc(), DynamicRoleModelNode::sync(), QQuickHeaderViewBasePrivate::syncSyncView(), QGnomeTheme::themeHint(), QCocoaTheme::themeHint(), QWindowsTheme::themeHint(), QQuickColorProvider::tint(), QLocale::toCurrencyString(), QLocale::toCurrencyString(), QLocale::toCurrencyString(), QCborValue::toVariant(), QJsonValue::toVariant(), QV4::QmlListWrapper::toVariant(), QV4::QQmlTypeWrapper::toVariant(), toVariant(), QDBusDemarshaller::toVariantInternal(), OrgBluezLEAdvertisingManager1Interface::UnregisterAdvertisement(), OrgBluezGattManager1Interface::UnregisterApplication(), OrgBluezProfileManager1Interface::UnregisterProfile(), QQuickTreeViewPrivate::updateRequiredProperties(), QQuickTableViewPrivate::updateSelectedOnAllDelegateItems(), DynamicRoleModelNode::updateValues(), QQmlStringConverters::variantFromString(), QGeoPath::variantPath(), QHeaderDataProxyModel::variantValue(), writeProperty(), OrgBluezGattCharacteristic1Interface::WriteValue(), and OrgBluezGattDescriptor1Interface::WriteValue().
|
inline |
Definition at line 738 of file qvariant.h.
References d, QVariant::Private::data, and QVariant::Private::is_shared.
bool QVariant::isNull | ( | ) | const |
Returns true
if this is a null variant, false otherwise.
A variant is considered null if it contains no initialized value or a null pointer.
Definition at line 2542 of file qvariant.cpp.
References d, QVariant::Private::get(), QVariant::Private::is_null, QMetaType::IsPointer, isValid(), and metaType().
Referenced by QNetworkReplyHttpImplPrivate::_q_cacheLoadReadyRead(), QNetworkReplyImplPrivate::_q_copyReadyRead(), DarwinBluetooth::add_sequence_attribute(), DarwinBluetooth::add_sequence_attribute(), QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions(), QAbstractSpinBoxPrivate::bound(), QDeclarativeGeoMapItemView::componentComplete(), QNetworkAccessManager::createRequest(), QNetworkReplyHttpImplPrivate::finished(), QNetworkReplyImplPrivate::finished(), AVFMetaData::fromAssetTrack(), QCborValue::fromVariant(), QDeclarativeGeoMapItemView::instantiateAllItems(), QSqlResultPrivate::isVariantNull(), QQuickTextDocumentWithImageResources::loadResource(), qMakeFieldInfo(), QNetworkReplyImpl::readData(), QNetworkReplyHttpImplPrivate::replyDownloadData(), QSqlTableModel::setData(), QQuickTreeViewPrivate::setModelImpl(), QTextBlockFormat::tabPositions(), and QMimeData::text().
|
inline |
Returns true
if the storage type of this variant is not QMetaType::UnknownType; otherwise returns false
.
Definition at line 707 of file qvariant.h.
References d, QMetaType::isValid(), and QVariant::Private::type().
Referenced by QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(), QQnxWindow::QQnxWindow(), QQnxWindow::QQnxWindow(), QPdfDocumentPrivate::_q_tryLoadingWithSizeFromContentHeader(), QQuickAnimatorPrivate::apply(), QQuickItemPrivate::canAcceptTabFocus(), QPrinterPrivate::changeEngines(), QTreeModel::clearItemData(), constructFromJSValue(), QWindowsMimeRegistry::convertToMime(), QQuickComboBoxPrivate::createDelegateModel(), QWindowsIntegration::createPlatformWindow(), QNetworkAccessManager::createRequest(), QWidgetPrivate::createTLSysExtra(), QQuickPropertyAnimation::createTransitionActions(), QAbstractItemModelTesterPrivate::data(), QAndroidInputContext::deleteSurroundingText(), doWriteProperties(), doWriteProperties(), doWriteProperties(), doWriteProperty(), QComboMenuDelegate::editorEvent(), QSortedModelEngine::filter(), QUnsortedModelEngine::filter(), WindowCreationData::fromWindow(), getAbsoluteCursorPosition(), getBlockPosition(), QNetworkReplyImplPrivate::getDownloadBuffer(), QAndroidInputContext::getExtractedText(), QIBusProxy::getGlobalEngine(), QAndroidInputContext::getTextAfterCursor(), QAndroidInputContext::getTextBeforeCursor(), QGeoJson::importGeoJson(), QQuickFontDialogImpl::init(), QQuickTumblerAttachedPrivate::init(), QNetworkReplyHttpImplPrivate::initCacheSaveDevice(), QNetworkReplyImplPrivate::initCacheSaveDevice(), QHeaderView::initStyleOptionForIndex(), QComboBox::insertItem(), QQuickFolderListModel::isFolder(), QDeclarativePluginParameter::isInitialized(), isNull(), QAbstractItemModel::itemData(), QTreeModel::itemData(), keywords(), QQmlSettingsPrivate::load(), load(), QPdfDocumentPrivate::load(), QQmlDelegateChoice::match(), QtObject::matrix4x4(), QHeaderView::paintEvent(), QNetworkReplyHttpImplPrivate::postRequest(), QInputMethod::queryFocusObject(), QVariantAnimationPrivate::recalculateCurrentInterval(), QWindowsInputContext::reconvertString(), save(), QHeaderView::sectionSizeFromContents(), QBluetoothServiceInfo::serviceClassUuids(), QQuickFontDialogImpl::setCurrentFont(), QQmlListAccessor::setList(), QDeclarativePluginParameter::setName(), QQuickLayoutItemProxy::setTarget(), QNetworkReplyImplPrivate::setup(), QNetworkReplyWasmImplPrivate::setup(), QHeaderViewPrivate::setupSectionIndicator(), QDeclarativePluginParameter::setValue(), QCocoaWindow::shouldRefuseKeyWindowAndFirstResponder(), QQmlPrivate::storeObjectAsVariant(), systemFallbackSearchPaths(), systemFallbackThemeName(), systemIconSearchPaths(), systemThemeName(), QTestPrivate::testDataGuiRoles(), testShowWithoutActivating(), QtWaylandClient::testShowWithoutActivating(), themeableHint(), themeableHint(), toVariant(), QV4::SequencePrototype::toVariant(), QQuickPropertyAction::transition(), tryConvertAndAssign(), QQuickFileDialogImplPrivate::updateSelectedFile(), QAndroidInputContext::updateSelectionHandles(), QWinRegistryKey::value(), QHeaderView::viewportEvent(), and QListView::viewportSizeHint().
void QVariant::load | ( | QDataStream & | s | ) |
Internal function for loading a variant from stream s.
Use the stream operators instead.
Definition at line 1230 of file qvariant.cpp.
References clear(), constData(), create(), d, QMetaType::fromName(), QMetaType::id(), QVariant::Private::is_null, isValid(), QMetaType::load(), MapFromThreeCount, mapIdFromQt3ToCurrent, qint8, Qt5FirstGuiType, Qt5LastGuiType, Qt5RegExp, Qt5SizePolicy, Qt5UserType, Qt6ToQt5GuiTypeDelta, QDataStream::Qt_4_0, QDataStream::Qt_4_2, QDataStream::Qt_5_0, QDataStream::Qt_6_0, qWarning, QDataStream::ReadCorruptData, QVariant::Private::type(), typeId(), QMetaType::UnknownType, and QMetaType::User.
QMetaType QVariant::metaType | ( | ) | const |
Returns the QMetaType of the value stored in the variant.
Definition at line 1069 of file qvariant.cpp.
References d, and QVariant::Private::type().
Referenced by QQmlListReference::QQmlListReference(), appendVariant(), QQmlJS::Dom::SimpleObjectWrapT< T >::asT(), QQmlListAccessor::at(), QSSGQmlUtilities::builtinQmlType(), QV4::coerce(), compare(), convertJSValueToVariantType(), QQmlListAccessor::count(), QSqlResult::exec(), QV4::Moth::VME::exec(), QOCICols::execBatch(), fromMatchingType(), QV4::ExecutionEngine::fromVariant(), QCborValue::fromVariant(), QJsonDocument::fromVariant(), QJsonValue::fromVariant(), QV4::ExecutionEngine::fromVariant(), QQC2::QWindowsStylePrivate::isDarkMode(), isNull(), QQmlSettingsPrivate::load(), QQmlVMEMetaObject::metaCall(), QV4::ExecutionEngine::metaTypeFromJS(), QQmlJS::Dom::SimpleObjectWrapT< T >::mutableAsT(), QDBusConnectionPrivate::prepareReply(), QQmlSettingsPrivate::readProperty(), ListModel::set(), QQmlListAccessor::set(), QQmlListAccessor::setList(), QV4::Heap::Sequence::setVariant(), QtSharedPointer::sharedPointerFromVariant_internal(), QQmlPrivate::storeFallbackAsVariant(), QQmlPrivate::storeObjectAsVariant(), QQuickLabsPlatformMenuItem::sync(), toVariant(), QV4::SequencePrototype::toVariant(), QPermission::type(), UntypedProxyProperty::type(), QQuick3DCustomMaterial::updateSpatialNode(), QQuick3DEffect::updateSpatialNode(), QQmlOpenMetaObjectPrivate::Property::value(), QQuickComboBoxDelegateModel::variantValue(), and QtSharedPointer::weakPointerFromVariant_internal().
void QVariant::save | ( | QDataStream & | s | ) | const |
Internal function for saving a variant to the stream s.
Use the stream operators instead.
Definition at line 1310 of file qvariant.cpp.
References QVariant(), constData(), d, QMetaType::FirstGuiType, i, QMetaType::id(), QVariant::Private::is_null, isValid(), QMetaType::LastCoreType, QMetaType::LastGuiType, MapFromThreeCount, mapIdFromQt3ToCurrent, QMetaType::name(), Q_ASSERT_X, qint8, Qt5KeySequence, Qt5LastCoreType, Qt5LastGuiType, Qt5QQuaternion, Qt5SizePolicy, Qt5UserType, Qt6ToQt5GuiTypeDelta, QDataStream::Qt_4_0, QDataStream::Qt_4_2, QDataStream::Qt_5_0, QDataStream::Qt_6_0, qWarning, QMetaType::save(), QVariant::Private::type(), QtMetaTypePrivate::typedefNameForType(), typeId(), typeName(), and QMetaType::User.
Referenced by operator<<().
Copies value over this QVariant.
It is equivalent to simply assigning value to this QVariant.
Definition at line 500 of file qvariant.h.
Moves value over this QVariant.
It is equivalent to simply move assigning value to this QVariant.
Definition at line 505 of file qvariant.h.
|
inline |
Stores a copy of value.
If {T} is a type that QVariant doesn't support, QMetaType is used to store the value. A compile error will occur if QMetaType doesn't handle the type.
Example:
Definition at line 488 of file qvariant.h.
References d.
Referenced by QIBusAttributeList::serializeTo(), and QIBusPlatformInputContext::update().
Swaps variant other with this variant. This operation is very fast and never fails.
Definition at line 334 of file qvariant.h.
Referenced by QDBusVariant::swap().
QBitArray QVariant::toBitArray | ( | ) | const |
Returns the variant as a QBitArray if the variant has userType() \l QMetaType::QBitArray; otherwise returns an empty bit array.
Definition at line 1868 of file qvariant.cpp.
bool QVariant::toBool | ( | ) | const |
Returns the variant as a bool if the variant has userType() Bool.
Returns true
if the variant has userType() \l QMetaType::Bool, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::UInt, or \l QMetaType::ULongLong and the value is non-zero, or if the variant has type \l QMetaType::QString or \l QMetaType::QByteArray and its lower-case content is not one of the following: empty, "0" or "false"; otherwise returns false
.
Definition at line 1980 of file qvariant.cpp.
References constData(), QMetaType::convert(), d, QVariant::Private::get(), and QVariant::Private::type().
Referenced by QGeoCodingManagerEngineMapbox::QGeoCodingManagerEngineMapbox(), QGeoCodingManagerEngineOsm::QGeoCodingManagerEngineOsm(), QGeoMappingManagerEngineMapboxGL::QGeoMappingManagerEngineMapboxGL(), QGeoRoutingManagerEngineMapbox::QGeoRoutingManagerEngineMapbox(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(), QNetworkReplyImplPrivate::QNetworkReplyImplPrivate(), QPlaceManagerEngineMapbox::QPlaceManagerEngineMapbox(), QPlaceManagerEngineOsm::QPlaceManagerEngineOsm(), QWindowsWindow::QWindowsWindow(), QNetworkAccessManagerPrivate::_q_replyFinished(), QTextFormat::boolProperty(), QQuickItemPrivate::canAcceptTabFocus(), QNetworkReplyHttpImplPrivate::createCache(), QNetworkReplyImplPrivate::createCache(), QNetworkReplyWasmImplPrivate::doSendRequest(), QPixmapStyle::drawComboBox(), QWindowsVistaStyle::drawControl(), QPixmapStyle::drawControl(), QPixmapStyle::drawPanelItemViewItem(), dumpAttributeVariant(), QWindow::event(), QQuickMenuBar::eventFilter(), QPSQLDriver::formatValue(), QSqlDriver::formatValue(), QCborValue::fromVariant(), QJsonValue::fromVariant(), QWidgetWindow::handleMouseEvent(), BreakPointHandler::handleSetBreakpoint(), QUnifiedTimer::installAnimationDriver(), QQuickFolderListModel::isFolder(), QPixmapStyle::itemViewSizeFromContents(), QQmlNativeDebugConnector::open(), QQuickWindowPrivate::polishItems(), QNetworkReplyHttpImplPrivate::postRequest(), queryInputMethod(), QTextEditPrivate::relayoutDocument(), replyFinished(), QTextEdit::resizeEvent(), QGraphicsItemPrivate::setEnabledHelper(), QStyleHints::setFocusOnTouchRelease(), setPenAndDrawBackground(), QGraphicsItem::setSelected(), QNetworkReplyImplPrivate::setup(), QNetworkReplyWasmImplPrivate::setup(), QDialogPrivate::setVisible(), QGraphicsItemPrivate::setVisibleHelper(), QCocoaWindow::shouldRefuseKeyWindowAndFirstResponder(), QStyleHints::showIsFullScreen(), QStyleHints::showIsMaximized(), QStyleHints::showShortcutsInContextMenus(), QStyleHints::singleClickActivation(), QQC2::QWindowsStyle::styleHint(), QImageReader::supportsAnimation(), testShowWithoutActivating(), QtWaylandClient::testShowWithoutActivating(), QQuickFileDialogImplPrivate::updateSelectedFile(), QAndroidInputContext::updateSelectionHandles(), QStyleHints::useRtlExtensions(), variantHash(), QQuickControlPrivate::warnIfCustomizationNotSupported(), QtBluezPeripheralDescriptor::WriteValue(), and QtBluezPeripheralCharacteristic::WriteValue().
QByteArray QVariant::toByteArray | ( | ) | const |
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMetaType::QString (converted using QString::fromUtf8()); otherwise returns an empty byte array.
Definition at line 1593 of file qvariant.cpp.
Referenced by QAndroidStyle::AndroidGradientDrawable::AndroidGradientDrawable(), QQnxWindow::QQnxWindow(), QQnxWindow::QQnxWindow(), appendVariant(), QXcbWindow::create(), QKmsDevice::createScreenForConnector(), QFileDialogPrivate::createWidgets(), dumpAttributeVariant(), QOCICols::execBatch(), QDB2Driver::formatValue(), QMYSQLDriver::formatValue(), QODBCDriver::formatValue(), QPSQLDriver::formatValue(), QSqlDriver::formatValue(), QCborValue::fromVariant(), QFileDialogPrivate::init(), keywords(), QQmlPreviewPosition::loadWindowPositionSettings(), main(), QNetworkReplyHttpImplPrivate::postRequest(), resolveSetting(), resolveSetting(), resolveSetting(), QQuickShaderEffectPrivate::setMesh(), QImageReader::subType(), and QTextOdfWriter::writeInlineCharacter().
QChar QVariant::toChar | ( | ) | const |
Returns the variant as a QChar if the variant has userType() \l QMetaType::QChar, \l QMetaType::Int, or \l QMetaType::UInt; otherwise returns an invalid QChar.
Definition at line 1857 of file qvariant.cpp.
Referenced by QStyleHints::passwordMaskCharacter(), QCommonStyle::styleHint(), and QQC2::QCommonStyle::styleHint().
QDate QVariant::toDate | ( | ) | const |
Returns the variant as a QDate if the variant has userType() \l QMetaType::QDate, \l QMetaType::QDateTime, or \l QMetaType::QString; otherwise returns an invalid date.
If the type() is \l QMetaType::QString, an invalid date will be returned if the string cannot be parsed as a Qt::ISODate format date.
Definition at line 1529 of file qvariant.cpp.
Referenced by QDateTimeEditPrivate::emitSignals(), QIBaseDriver::formatValue(), QOCIDriver::formatValue(), QSqlDriver::formatValue(), QDateTimeEditPrivate::init(), and QDateTimeEditPrivate::updateTimeZone().
QDateTime QVariant::toDateTime | ( | ) | const |
Returns the variant as a QDateTime if the variant has userType() \l QMetaType::QDateTime, \l QMetaType::QDate, or \l QMetaType::QString; otherwise returns an invalid date/time.
If the type() is \l QMetaType::QString, an invalid date/time will be returned if the string cannot be parsed as a Qt::ISODate format date/time.
Definition at line 1563 of file qvariant.cpp.
Referenced by DateFormatProxyModel::data(), QDB2Driver::formatValue(), QIBaseDriver::formatValue(), QMYSQLDriver::formatValue(), QOCIDriver::formatValue(), QODBCDriver::formatValue(), QPSQLDriver::formatValue(), QSqlDriver::formatValue(), QCborValue::fromVariant(), QDateTimeEditPrivate::getMaximum(), QDateTimeEditPrivate::getMinimum(), QGstreamerMetaData::setMetaData(), QDateTimeEditPrivate::stepBy(), QDateTimeEditPrivate::updateTimeZone(), and QDateTimeEditPrivate::validateAndInterpret().
double QVariant::toDouble | ( | bool * | ok = nullptr | ) | const |
Returns the variant as a double if the variant has userType() \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; otherwise returns 0.0.
If ok is non-null: {*}{ok} is set to true if the value could be converted to a double; otherwise
{*}{ok} is set to false.
Definition at line 2003 of file qvariant.cpp.
Referenced by QDoubleSpinBoxPrivate::calculateAdaptiveDecimalStep(), cellEdgeData(), QDeclarativeGeoMap::fitViewportToGeoShape(), QMYSQLDriver::formatValue(), QPSQLDriver::formatValue(), QCborValue::fromVariant(), QJsonValue::fromVariant(), importPosition(), QAccessibleBridgeUtils::performEffectiveAction(), QGstreamerMetaData::setMetaData(), QtAndroidAccessibility::textFromValue(), QDoubleSpinBoxPrivate::validateAndInterpret(), variantHash(), and QSSGQmlUtilities::variantToQml().
float QVariant::toFloat | ( | bool * | ok = nullptr | ) | const |
Returns the variant as a float if the variant has userType() \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; otherwise returns 0.0.
If ok is non-null: {*}{ok} is set to true if the value could be converted to a double; otherwise
{*}{ok} is set to false.
Definition at line 2022 of file qvariant.cpp.
Referenced by QQuickTableViewPrivate::canUnloadTableEdge(), QPSQLDriver::formatValue(), QuickTestResult::fuzzyCompare(), QQuickRotationAnimatorJob::updateCurrentTime(), and variantHash().
QVariantHash QVariant::toHash | ( | ) | const |
Returns the variant as a QHash<QString, QVariant> if the variant has type() \l QMetaType::QVariantHash; otherwise returns an empty map.
Definition at line 1512 of file qvariant.cpp.
Referenced by QCborValue::fromVariant(), QJsonDocument::fromVariant(), and QJsonValue::fromVariant().
int QVariant::toInt | ( | bool * | ok = nullptr | ) | const |
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; otherwise returns 0.
If ok is non-null: {*}{ok} is set to true if the value could be converted to an int; otherwise
{*}{ok} is set to false.
{Warning:} If the value is convertible to a \l QMetaType::LongLong but is too large to be represented in an int, the resulting arithmetic overflow will not be reflected in ok. A simple workaround is to use QString::toInt().
Definition at line 1907 of file qvariant.cpp.
Referenced by QAndroidStyle::AndroidGradientDrawable::AndroidGradientDrawable(), QAndroidStyle::AndroidLayerDrawable::AndroidLayerDrawable(), NmeaParameters::NmeaParameters(), NmeaSatelliteSource::NmeaSatelliteSource(), QIconTheme::QIconTheme(), QPlaceManagerEngineOsm::QPlaceManagerEngineOsm(), QQnxWindow::QQnxWindow(), QQuickContainerPrivate::_q_currentIndexChanged(), QNetworkReplyHttpImplPrivate::_q_metaDataChanged(), QCalendarWidgetPrivate::_q_monthChanged(), QQuickTumblerPrivate::_q_onViewCountChanged(), QQuickTumblerPrivate::_q_onViewCurrentIndexChanged(), QWaylandInputMethodEventBuilder::buildCommit(), QSpinBoxPrivate::calculateAdaptiveDecimalStep(), QQuickTumblerAttachedPrivate::calculateDisplacement(), DocumentFile::canWrite(), QT_BEGIN_NAMESPACE::channel_or_psm(), QNetworkAccessManager::createRequest(), QKmsDevice::createScreenForConnector(), QPlatformThemePrivate::currentKeyPlatforms(), QStyleHints::cursorFlashTime(), QMYSQLResult::data(), QPlatformTheme::defaultThemeHint(), DocumentsContract::deleteDocument(), QQuickDeliveryAgentPrivate::deliverTouchAsMouse(), QNetworkReplyWasmImplPrivate::doSendRequest(), QQC2_NAMESPACE::QMacStyle::drawComplexControl(), QMacStyle::drawComplexControl(), QWindowsVistaStyle::drawComplexControl(), QWindowsVistaStyle::drawControl(), QWindowsVistaStyle::drawPrimitive(), drawTextItemDecoration(), dumpAttributeVariant(), QComboMenuDelegate::editorEvent(), getAbsoluteCursorPosition(), getBlockPosition(), QAndroidInputContext::handleLocationChanged(), QQuickFlickablePrivate::handleReleaseEvent(), BreakPointHandler::handleRemoveBreakpoint(), BreakPointHandler::handleSetBreakpoint(), QImageReader::imageFormat(), QQuickTumblerAttachedPrivate::init(), initThemeHints(), QAbstractSpinBox::inputMethodQuery(), QTextFormat::intProperty(), DocumentFile::isVirtual(), QStyleHints::keyboardInputInterval(), QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(), main(), QQmlDelegateChoice::match(), QNetworkReplyImplPrivate::metaDataChanged(), QStyleHints::mouseDoubleClickDistance(), QStyleHints::mouseDoubleClickInterval(), QStyleHints::mousePressAndHoldInterval(), QStyleHints::mouseQuickSelectionThreshold(), DocumentsContract::moveDocument(), QTextFormat::objectIndex(), parseAlignment(), parseOptions(), QStyleHints::passwordMaskDelay(), QQC2::QCommonStyle::pixelMetric(), QCommonStyle::pixelMetric(), QNetworkReplyHttpImplPrivate::postRequest(), qGetTableInfo(), qMakeFieldInfo(), QSqlQueryModel_snippets(), QSqlTableModel_snippets(), QWindowsInputContext::reconvertString(), QWidgetTextControlPrivate::rectForPosition(), DocumentsContract::renameDocument(), QNetworkReplyHttpImplPrivate::sendCacheContents(), QQmlDebugTranslationServicePrivate::sendTranslatableTextOccurrences(), QQuickTumblerPrivate::setCurrentIndex(), QGstreamerMetaData::setMetaData(), QPlatformInputContext::setSelectionOnFocusObject(), QSSGRhiShaderPipeline::setUniformValue(), QNetworkReplyFileImpl::size(), snippet_ctor2(), sql_intro_snippets(), QStyleHints::startDragDistance(), QStyleHints::startDragTime(), QStyleHints::startDragVelocity(), QCommonStyle::styleHint(), QQC2::QCommonStyle::styleHint(), QWindowsScreen::subpixelAntialiasingTypeHint(), QPrinter::supportedResolutions(), QQuickLabsPlatformMenuItem::sync(), QQuickTumblerPrivate::syncCurrentIndex(), QStyleHints::tabFocusBehavior(), QQuickTreeViewDelegatePrivate::toggleExpanded(), QCss::Value::toString(), QStyleHints::touchDoubleTapDistance(), QAndroidInputContext::touchDown(), QImageReader::transformation(), updTable2(), QStyleHints::useHoverEffects(), QSpinBoxPrivate::validateAndInterpret(), variantHash(), QListView::viewportSizeHint(), QStyleHints::wheelScrollLines(), and QIIOFHelper::writeImage().
QJsonArray QVariant::toJsonArray | ( | ) | const |
Returns the variant as a QJsonArray if the variant has userType() \l QJsonArray; otherwise returns a default constructed QJsonArray.
Definition at line 1829 of file qvariant.cpp.
Referenced by QCborValue::fromVariant(), and QJsonValue::fromVariant().
QJsonDocument QVariant::toJsonDocument | ( | ) | const |
Returns the variant as a QJsonDocument if the variant has userType() \l QJsonDocument; otherwise returns a default constructed QJsonDocument.
Definition at line 1842 of file qvariant.cpp.
Referenced by QCborValue::fromVariant(), and QJsonValue::fromVariant().
QJsonObject QVariant::toJsonObject | ( | ) | const |
Returns the variant as a QJsonObject if the variant has userType() \l QJsonObject; otherwise returns a default constructed QJsonObject.
Definition at line 1816 of file qvariant.cpp.
Referenced by QCborValue::fromVariant(), and QJsonValue::fromVariant().
QJsonValue QVariant::toJsonValue | ( | ) | const |
Returns the variant as a QJsonValue if the variant has userType() \l QJsonValue; otherwise returns a default constructed QJsonValue.
Definition at line 1803 of file qvariant.cpp.
Referenced by QCborValue::fromVariant(), and QJsonValue::fromVariant().
QLine QVariant::toLine | ( | ) | const |
Returns the variant as a QLine if the variant has userType() \l QMetaType::QLine; otherwise returns an invalid QLine.
Definition at line 1687 of file qvariant.cpp.
QLineF QVariant::toLineF | ( | ) | const |
Returns the variant as a QLineF if the variant has userType() \l QMetaType::QLineF; otherwise returns an invalid QLineF.
Definition at line 1674 of file qvariant.cpp.
QVariantList QVariant::toList | ( | ) | const |
Returns the variant as a QVariantList if the variant has userType() \l QMetaType::QVariantList.
If it doesn't, QVariant will attempt to convert the type to a list and then return it. This will succeed for any type that has registered a converter to QVariantList or which was declared as a sequential container using \l{Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE}. If none of those conditions are true, this function will return an empty list.
Definition at line 2057 of file qvariant.cpp.
Referenced by QAndroidStyle::AndroidGradientDrawable::AndroidGradientDrawable(), QAndroidStyle::AndroidLayerDrawable::AndroidLayerDrawable(), QAndroidStyle::AndroidStateDrawable::AndroidStateDrawable(), QOCICols::execBatch(), QCborValue::fromVariant(), QJsonDocument::fromVariant(), QJsonValue::fromVariant(), QTextFormat::lengthVectorProperty(), QDeclarativePlace::place(), QQmlTableModel::setRows(), and QQuickComboBoxDelegateModel::variantValue().
QLocale QVariant::toLocale | ( | ) | const |
Returns the variant as a QLocale if the variant has userType() \l QMetaType::QLocale; otherwise returns an invalid QLocale.
Definition at line 1731 of file qvariant.cpp.
Referenced by QQuickControlPrivate::calcLocale().
Returns the variant as a long long int if the variant has userType() \l QMetaType::LongLong, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; otherwise returns 0.
If ok is non-null: {*}
{ok} is set to true if the value could be converted to an int; otherwise
{*}
{ok} is set to false.
Definition at line 1946 of file qvariant.cpp.
Referenced by QNetworkReplyHttpImplPrivate::_q_cacheLoadReadyRead(), QNetworkReplyImplPrivate::_q_copyReadyRead(), QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions(), QMYSQLResult::data(), QNetworkReplyHttpImplPrivate::finished(), QNetworkReplyImplPrivate::finished(), QCborValue::fromVariant(), QJsonValue::fromVariant(), QNetworkReplyImplPrivate::getDownloadBuffer(), DocumentFile::length(), QNetworkReplyHttpImplPrivate::postRequest(), QNetworkReplyImpl::readData(), and QNetworkReplyHttpImplPrivate::replyDownloadData().
QVariantMap QVariant::toMap | ( | ) | const |
Returns the variant as a QVariantMap if the variant has type() \l QMetaType::QVariantMap.
If it doesn't, QVariant will attempt to convert the type to a map and then return it. This will succeed for any type that has registered a converter to QVariantMap or which was declared as a associative container using \l{Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE}. If none of those conditions are true, this function will return an empty map.
Definition at line 1501 of file qvariant.cpp.
Referenced by QAndroidStyle::Android9PatchDrawable::Android9PatchDrawable(), QQmlTableModel::data(), QIOSMenu::eventFilter(), QCborValue::fromVariant(), QJsonDocument::fromVariant(), QJsonValue::fromVariant(), QQmlTableModel::setData(), and QV4::ExecutionEngine::variantMapFromJS().
QPoint QVariant::toPoint | ( | ) | const |
Returns the variant as a QPoint if the variant has userType() \l QMetaType::QPoint or \l QMetaType::QPointF; otherwise returns a null QPoint.
Definition at line 1608 of file qvariant.cpp.
Referenced by MainWindow::readSettings().
QPointF QVariant::toPointF | ( | ) | const |
Returns the variant as a QPointF if the variant has userType() \l QMetaType::QPoint or \l QMetaType::QPointF; otherwise returns a null QPointF.
Definition at line 1701 of file qvariant.cpp.
Referenced by QGraphicsItem::setPos(), and QGraphicsItem::setTransformOriginPoint().
Returns the variant as a qreal if the variant has userType() \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; otherwise returns 0.0.
If ok is non-null: {*}{ok} is set to true if the value could be converted to a double; otherwise
{*}{ok} is set to false.
Definition at line 2041 of file qvariant.cpp.
Referenced by QQuickTumblerPrivate::_q_onViewContentYChanged(), QQuickTumblerPrivate::_q_onViewOffsetChanged(), QQuickAnimatorPrivate::apply(), QQuickTumblerAttachedPrivate::calculateDisplacement(), QStyleHints::fontSmoothingGamma(), QStyleHints::keyboardAutoRepeatRateF(), QQuickTableViewPrivate::loadInitialTable(), parseBrushValue(), QFlickGestureRecognizer::recognize(), QGraphicsItem::setOpacity(), QGraphicsItem::setRotation(), QGraphicsItem::setScale(), QGraphicsItem::setZValue(), QQuickParentAnimation::transition(), and QQuickSpringAnimation::transition().
QRect QVariant::toRect | ( | ) | const |
Returns the variant as a QRect if the variant has userType() \l QMetaType::QRect; otherwise returns an invalid QRect.
Definition at line 1621 of file qvariant.cpp.
Referenced by QQC2_NAMESPACE::QMacStyle::drawComplexControl(), QMacStyle::drawComplexControl(), QWindowsVistaStyle::drawComplexControl(), QWindowsVistaStyle::drawControl(), QWindowsVistaStyle::drawPrimitive(), QScrollArea::ensureWidgetVisible(), and QWidgetWindow::handleContextMenuEvent().
QRectF QVariant::toRectF | ( | ) | const |
Returns the variant as a QRectF if the variant has userType() \l QMetaType::QRect or \l QMetaType::QRectF; otherwise returns an invalid QRectF.
Definition at line 1661 of file qvariant.cpp.
Referenced by QGraphicsTextItem::inputMethodQuery().
QSize QVariant::toSize | ( | ) | const |
Returns the variant as a QSize if the variant has userType() \l QMetaType::QSize; otherwise returns an invalid QSize.
Definition at line 1634 of file qvariant.cpp.
Referenced by QGraphicsScenePrivate::drawItemHelper(), QGraphicsSvgItem::maximumCacheSize(), MainWindow::readSettings(), QQuickShaderEffectPrivate::setMesh(), and QImageReader::size().
QSizeF QVariant::toSizeF | ( | ) | const |
Returns the variant as a QSizeF if the variant has userType() \l QMetaType::QSizeF; otherwise returns an invalid QSizeF.
Definition at line 1647 of file qvariant.cpp.
QString QVariant::toString | ( | ) | const |
Returns the variant as a QString if the variant has a userType() including, but not limited to:
\l QMetaType::QString, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::QDate, \l QMetaType::QDateTime, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QStringList, \l QMetaType::QTime, \l QMetaType::UInt, or \l QMetaType::ULongLong.
Calling QVariant::toString() on an unsupported variant returns an empty string.
Definition at line 1485 of file qvariant.cpp.
Referenced by QAndroidStyle::AndroidImageDrawable::AndroidImageDrawable(), GeoCodingManagerEngineEsri::GeoCodingManagerEngineEsri(), GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(), GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(), NmeaParameters::NmeaParameters(), QCtfLibImpl::QCtfLibImpl(), QGeoCodingManagerEngineMapbox::QGeoCodingManagerEngineMapbox(), QGeoCodingManagerEngineNokia::QGeoCodingManagerEngineNokia(), QGeoCodingManagerEngineOsm::QGeoCodingManagerEngineOsm(), QGeoMappingManagerEngineMapboxGL::QGeoMappingManagerEngineMapboxGL(), QGeoRoutingManagerEngineMapbox::QGeoRoutingManagerEngineMapbox(), QGeoRoutingManagerEngineNokia::QGeoRoutingManagerEngineNokia(), QGeoRoutingManagerEngineOsm::QGeoRoutingManagerEngineOsm(), QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(), QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(), QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(), QGeoTileFetcherNokia::QGeoTileFetcherNokia(), QIconTheme::QIconTheme(), QPlaceManagerEngineMapbox::QPlaceManagerEngineMapbox(), QPlaceManagerEngineNokiaV2::QPlaceManagerEngineNokiaV2(), QPlaceManagerEngineOsm::QPlaceManagerEngineOsm(), QInputDialogPrivate::_q_currentRowChanged(), QFileDialogPrivate::_q_enterDirectory(), QFileDialogPrivate::_q_goToDirectory(), QFileDialogPrivate::_q_navigateToParent(), QQuickTumblerPrivate::_q_onViewCurrentIndexChanged(), QFileDialogPrivate::_q_useNameFilter(), QLocale::amText(), QTextCharFormat::anchorNames(), appendVariant(), QSSGQmlUtilities::asString(), QWaylandInputMethodEventBuilder::buildCommit(), QmlLsp::QQmlCodeModel::buildPathsForFileUrl(), QSSGQmlUtilities::builtinQmlType(), QAbstractItemViewPrivate::checkMouseMove(), QT_BEGIN_NAMESPACE::checkUsageTerms(), QLocale::collation(), QtObject::colorEqual(), QAbstractItemModelTesterPrivate::columnsAboutToBeInserted(), QAbstractItemModelTesterPrivate::columnsAboutToBeMoved(), QAbstractItemModelTesterPrivate::columnsAboutToBeRemoved(), QAbstractItemModelTesterPrivate::columnsInserted(), QAbstractItemModelTesterPrivate::columnsMoved(), QAbstractItemModelTesterPrivate::columnsRemoved(), QuickTestResult::compare(), QQuickPropertyAnimationPrivate::convertVariant(), QGeoServiceProviderFactoryMapbox::createMappingManagerEngine(), QGeoServiceProviderFactoryMapbox::createPlaceManagerEngine(), GeoServiceProviderFactoryEsri::createRoutingManagerEngine(), QGeoServiceProviderFactoryMapbox::createRoutingManagerEngine(), QKmsDevice::createScreenForConnector(), QLocale::createSeparatedList(), QLocale::currencySymbol(), QLocale::dateFormat(), QLocale::dateTimeFormat(), QAndroidInputContext::deleteSurroundingText(), dumpAttributeVariant(), QDBusMessage::errorMessage(), QOCICols::execBatch(), extractLocalFileName(), QSortedModelEngine::filter(), QWindowsDirect2DPaintEnginePrivate::fontFaceFromFontEngine(), fontKeys(), for(), QPSQLDriver::formatValue(), QSqlDriver::formatValue(), QAndroidStyle::AndroidDrawable::fromMap(), QCborValue::fromVariant(), QJsonValue::fromVariant(), QuickTestResult::fuzzyCompare(), QAndroidInputContext::getExtractedText(), QImageReaderPrivate::getText(), QAndroidInputContext::getTextAfterCursor(), QAndroidInputContext::getTextBeforeCursor(), BreakPointHandler::handleSetBreakpoint(), QQmlToolingSettings::isSet(), QComboBoxPrivate::itemText(), QAbstractItemView::keyPressEvent(), main(), QQmlDelegateChoice::match(), QV4::VariantPrototype::method_toString(), DocumentFile::mimeType(), QGregorianCalendar::monthName(), DocumentFile::name(), nameOfRemoteCentral(), QLocale::nativeLanguageName(), QLocale::nativeTerritoryName(), QQmlLocalStorage::openDatabaseSync(), QV4::SequenceDefaultCompareFunctor::operator()(), QCompleter::pathFromIndex(), QBluetoothSocketPrivateBluez::peerName(), QLocale::pmText(), QOCIDriver::primaryIndex(), qDBusPropertyGet(), qDBusPropertyGetAll(), qDBusPropertySet(), qMakeFieldInfo(), qmlsqldatabase_executeSql(), QLocale::quoteString(), readInputFile(), QWindowsInputContext::reconvertString(), QPSQLResult::record(), QBluetoothServiceInfoPrivate::registerService(), QQuickStyleSpec::resolve(), QFileDialogPrivate::retranslateStrings(), QAbstractItemModelTesterPrivate::rowsAboutToBeInserted(), QAbstractItemModelTesterPrivate::rowsAboutToBeMoved(), QAbstractItemModelTesterPrivate::rowsAboutToBeRemoved(), QAbstractItemModelTesterPrivate::rowsInserted(), QAbstractItemModelTesterPrivate::rowsMoved(), QAbstractItemModelTesterPrivate::rowsRemoved(), QFileSystemModel::setData(), QUrlModel::setData(), QFileDialogComboBox::setHistory(), QGstreamerMetaData::setMetaData(), showParserMessage(), QFileDialogComboBox::showPopup(), QSortedModelEngine::sortOrder(), sql_intro_snippets(), QGregorianCalendar::standaloneMonthName(), QCalendarBackend::standaloneWeekDayName(), QQuickColorProvider::stringFromRgba(), QTextFormat::stringProperty(), QQuickLabsPlatformMenuItem::sync(), systemFallbackThemeName(), systemLocaleString(), systemThemeName(), QMimeData::text(), QAbstractItemDelegatePrivate::textForRole(), QtAndroidAccessibility::textFromValue(), QLocale::timeFormat(), QLocale::toCurrencyString(), QLocale::toCurrencyString(), QLocale::toCurrencyString(), QCss::Value::toString(), QSystemLocalePrivate::toString(), QLocale::toString(), QLocale::toString(), QLocale::toString(), QLocale::toString(), QLocale::toString(), variantHash(), QSSGQmlUtilities::variantToQml(), QHeaderView::viewportEvent(), QCalendarBackend::weekDayName(), and QLocaleData::zeroUcs().
QStringList QVariant::toStringList | ( | ) | const |
Returns the variant as a QStringList if the variant has userType() \l QMetaType::QStringList, \l QMetaType::QString, or \l QMetaType::QVariantList of a type that can be converted to QString; otherwise returns an empty list.
Definition at line 1465 of file qvariant.cpp.
Referenced by QIconTheme::QIconTheme(), QTextCharFormat::anchorNames(), QCborValue::fromVariant(), QJsonDocument::fromVariant(), QJsonValue::fromVariant(), QLibraryInfo::platformPluginArguments(), qtValue(), QQuickTableViewPrivate::setRequiredProperty(), systemFallbackSearchPaths(), systemIconSearchPaths(), and QLocale::uiLanguages().
QTime QVariant::toTime | ( | ) | const |
Returns the variant as a QTime if the variant has userType() \l QMetaType::QTime, \l QMetaType::QDateTime, or \l QMetaType::QString; otherwise returns an invalid time.
If the type() is \l QMetaType::QString, an invalid time will be returned if the string cannot be parsed as a Qt::ISODate format time.
Definition at line 1546 of file qvariant.cpp.
Referenced by QDateTimeEditPrivate::emitSignals(), QIBaseDriver::formatValue(), QPSQLDriver::formatValue(), QSqlDriver::formatValue(), QDateTimeEditPrivate::init(), and QDateTimeEditPrivate::updateTimeZone().
Returns the variant as an unsigned int if the variant has userType() \l QMetaType::UInt, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, or \l QMetaType::ULongLong; otherwise returns 0.
If ok is non-null: {*}{ok} is set to true if the value could be converted to an unsigned int; otherwise
{*}{ok} is set to false.
{Warning:} If the value is convertible to a \l QMetaType::ULongLong but is too large to be represented in an unsigned int, the resulting arithmetic overflow will not be reflected in ok. A simple workaround is to use QString::toUInt().
Definition at line 1929 of file qvariant.cpp.
Referenced by QXdgDesktopPortalTheme::QXdgDesktopPortalTheme(), QtBluezPeripheralGattObject::accessEvent(), QNetworkManagerInterface::connectivityState(), QLocalSocket::connectToServer(), QMYSQLResult::data(), QQC2_NAMESPACE::QMacStyle::drawComplexControl(), QMacStyle::drawComplexControl(), dumpAttributeVariant(), metaDataValue(), QBluetoothServiceInfo::protocolServiceMultiplexer(), QtBluezPeripheralDescriptor::ReadValue(), QtBluezPeripheralCharacteristic::ReadValue(), QBluetoothServiceInfoPrivate::serverChannel(), and QNetworkManagerInterface::state().
qulonglong QVariant::toULongLong | ( | bool * | ok = nullptr | ) | const |
Returns the variant as an unsigned long long int if the variant has type() \l QMetaType::ULongLong, \l QMetaType::Bool, \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, or \l QMetaType::UInt; otherwise returns 0.
If ok is non-null: {*}{ok} is set to true if the value could be converted to an int; otherwise
{*}{ok} is set to false.
Definition at line 1963 of file qvariant.cpp.
Referenced by QPdfDocumentPrivate::_q_tryLoadingWithSizeFromContentHeader(), QCborValue::fromVariant(), and QJsonValue::fromVariant().
QUrl QVariant::toUrl | ( | ) | const |
Returns the variant as a QUrl if the variant has userType() \l QMetaType::QUrl; otherwise returns an invalid QUrl.
Definition at line 1717 of file qvariant.cpp.
Referenced by QQuickImageSelector::componentComplete(), QQuickFolderBreadcrumbBarPrivate::dialogFolder(), dumpAttributeVariant(), QCborValue::fromVariant(), QJsonValue::fromVariant(), QSidebar::selectUrl(), ListModel::set(), and QPlaceIcon::url().
QUuid QVariant::toUuid | ( | ) | const |
Returns the variant as a QUuid if the variant has type() \l QMetaType::QUuid, \l QMetaType::QByteArray or \l QMetaType::QString; otherwise returns a default-constructed QUuid.
Definition at line 1789 of file qvariant.cpp.
Referenced by QCborValue::fromVariant(), and QJsonValue::fromVariant().
|
inline |
Returns the storage type of the value stored in the variant.
This is the same as metaType().id().
Definition at line 337 of file qvariant.h.
Referenced by DarwinBluetooth::add_attribute(), DarwinBluetooth::add_attribute(), dumpAttributeVariant(), QOCICols::execBatch(), QDeclarativeGeoMap::fitViewportToGeoShape(), QSqlResultPrivate::isVariantNull(), load(), QDeclarativePlace::place(), save(), QGstreamerMetaData::setMetaData(), QDeclarativeSearchModelBase::setSearchArea(), QtAndroidAccessibility::textFromValue(), and QSSGQmlUtilities::variantToQml().
const char * QVariant::typeName | ( | ) | const |
Returns the name of the type stored in the variant.
The returned strings describe the C++ datatype used to store the data: for example, "QFont", "QString", or "QVariantList". An Invalid variant returns 0.
Definition at line 1127 of file qvariant.cpp.
References d, QMetaType::name(), and QVariant::Private::type().
Referenced by QQmlProperty::propertyTypeName(), save(), QQmlTableModel::setRows(), and variantHash().
|
inline |
Definition at line 336 of file qvariant.h.
Referenced by DarwinBluetooth::add_attribute(), DarwinBluetooth::add_attribute(), QTextCharFormat::anchorNames(), QTextFormat::boolProperty(), QTextFormat::brushProperty(), QtObject::colorEqual(), QTextFormat::colorProperty(), QQuickPropertyAnimationPrivate::convertVariant(), QItemDelegate::decoration(), QTextFormat::doubleProperty(), QSqlDriver::formatValue(), QuickTestResult::fuzzyCompare(), QDateTimeEditPrivate::init(), QTextFormat::intProperty(), QComboBoxPrivate::itemIcon(), QTextFormat::lengthVectorProperty(), QQmlDesignerMetaObject::metaCall(), QTextFormat::objectIndex(), QTextFormat::penProperty(), QAccessibleBridgeUtils::performEffectiveAction(), QBluetoothServiceInfoPrivate::protocolDescriptor(), QQuickTableViewPrivate::qaim(), qtObjectFromJS(), QTextEditPrivate::relayoutDocument(), QTextEdit::resizeEvent(), QDeclarativeGeocodeModel::setBounds(), QQuickItemView::setModel(), QQuickPathView::setModel(), QQuickRepeater::setModel(), QQuick3DRepeater::setModel(), QQuickComboBox::setModel(), QItemDelegate::setModelData(), QStyledItemDelegate::setModelData(), QQuickTreeViewPrivate::setModelImpl(), QQmlTableModel::setRows(), QDeclarativeSearchModelBase::setSearchArea(), QTextFormat::stringProperty(), QQuickTableViewPrivate::syncModel(), variantHash(), and QTextOdfWriter::writeInlineCharacter().
|
inline |
Definition at line 523 of file qvariant.h.
|
inline |
Definition at line 511 of file qvariant.h.
Referenced by QQuickAbstractButtonPrivate::acceptKeyClick(), QtBluezPeripheralGattObject::accessEvent(), DarwinBluetooth::add_attribute< QBluetoothUuid >(), DarwinBluetooth::add_attribute< QBluetoothUuid >(), DarwinBluetooth::add_attribute< QString >(), DarwinBluetooth::add_attribute< QString >(), DarwinBluetooth::add_sequence_attribute(), DarwinBluetooth::add_sequence_attribute(), QQuickColorProvider::alpha(), QQuickDesignerSupport::anchorLineTarget(), QQmlJS::Dom::SimpleObjectWrapT< T >::asT(), QNetworkReply::attribute(), QQuickTumblerAttachedPrivate::calculateDisplacement(), QQuickScrollBarAttachedPrivate::cleanupHorizontal(), QQuickScrollBarAttachedPrivate::cleanupVertical(), QV4::coerce(), convertJSValueToVariantType(), cppQmlInterface(), QQuickComboBoxPrivate::createDelegateModel(), QQuickColorProvider::darker(), QDeclarativePlaceContentModel::data(), QSqlRelationalTableModel::data(), QTableWidgetItem::data(), QQmlEngineDebugClient::decode(), QAndroidInputContext::deleteSurroundingText(), QQC2_NAMESPACE::QMacStyle::drawComplexControl(), QMacStyle::drawComplexControl(), dumpAttributeVariant(), QQuickLayoutItemProxy::effectiveTarget(), QMacStyle::event(), QGroupBox::event(), exportFeature(), exportFeatureCollection(), QGeoJson::exportGeoJson(), exportGeometryCollection(), exportLineString(), exportMultiLineString(), exportMultiPoint(), exportMultiPolygon(), exportPoint(), exportPolygon(), QSGRhiShaderLinker::feedConstants(), findAttachedParent(), WindowCreationData::fromWindow(), QuickTestResult::fuzzyCompare(), QQmlDMAbstractItemModelData::get_property(), getAbsoluteCursorPosition(), getBlockPosition(), getPrimaryDevice(), QQuickContext2DStyle::gradient_proto_addColorStop(), QNetworkAccessBackend::header(), QNetworkReply::header(), if(), if(), importArrayOfArrayOfPositions(), importArrayOfPositions(), importFeatureCollection(), QGeoJson::importGeoJson(), importGeometryCollection(), importImp(), importMultiLineString(), importMultiPoint(), importMultiPolygon(), QQuickScrollBarAttachedPrivate::initHorizontal(), QDeclarativePlaceContentModel::initializeCollection(), QQuickScrollBarAttachedPrivate::initVertical(), QQuickToolTipAttachedPrivate::instance(), QQC2::QWindowsStylePrivate::isDarkMode(), QAbstractButton::keyPressEvent(), QComboBox::keyPressEvent(), QQuickComboBox::keyPressEvent(), QAbstractButton::keyReleaseEvent(), QQuickComboBox::keyReleaseEvent(), QQuickColorProvider::lighter(), QWindowsMenuBar::menuBarOf(), QQuickJSContext2DPrototype::method_createPattern(), QQuickJSContext2D::method_set_fillStyle(), QQuickJSContext2D::method_set_strokeStyle(), QQmlJS::Dom::SimpleObjectWrapT< T >::mutableAsT(), QQuickOverlay::overlay(), QLibraryInfoPrivate::path(), QDeclarativePlace::place(), platformButtonLayout(), QtWaylandClient::QWaylandWindow::property(), QtWaylandClient::QWaylandWindow::property(), QQuickShaderEffectPrivate::propertyChanged(), QBluetoothServiceInfoPrivate::protocolDescriptor(), QQuickTableViewPrivate::qaim(), QTreeWidgetItem::read(), QQmlSettingsPrivate::readProperty(), QBluetoothServiceInfoPrivate::registerService(), QQmlDebugTranslationServicePrivate::sendTranslatableTextOccurrences(), QBluetoothServiceInfo::serviceClassUuids(), QDeclarativeGeocodeModel::setBounds(), QQmlListAccessor::setList(), QGstreamerMetaData::setMetaData(), QQuickItemView::setModel(), QQuickPathView::setModel(), QQuickRepeater::setModel(), QQuick3DRepeater::setModel(), QQuickComboBox::setModel(), QQuickTreeViewPrivate::setModelImpl(), QQuickHeaderViewBasePrivate::setModelImpl(), QMacPrintEngine::setProperty(), QWin32PrintEngine::setProperty(), QQmlTableModel::setRows(), QDeclarativeSearchModelBase::setSearchArea(), QQuickLayoutItemProxy::setTarget(), QSSGRhiShaderPipeline::setUniformValue(), QQmlOpenMetaObjectPrivate::Property::setValue(), QMediaMetaData::stringValue(), QQuickLabsPlatformMenuItem::sync(), DynamicRoleModelNode::sync(), QSGRhiShaderEffectNode::syncMaterial(), QQuickTableViewPrivate::syncModel(), QQuickColorProvider::tint(), toVariant(), QSqlRelationalTableModelPrivate::translateFieldNames(), QAndroidInputContext::updateSelectionHandles(), QQuick3DCustomMaterial::updateSpatialNode(), QQuick3DEffect::updateSpatialNode(), DynamicRoleModelNode::updateValues(), QMediaMetaData::value(), QSSGQmlUtilities::valueToQml(), DarwinBluetooth::variant_to_nsnumber< char >(), DarwinBluetooth::variant_to_nsnumber< int >(), DarwinBluetooth::variant_to_nsnumber< short >(), DarwinBluetooth::variant_to_nsnumber< unsigned >(), DarwinBluetooth::variant_to_nsnumber< unsigned char >(), DarwinBluetooth::variant_to_nsnumber< unsigned short >(), QSSGQmlUtilities::variantToQml(), and QV4::QQmlTypeWrapper::virtualIsEqualTo().
|
inline |
Returns a mutable view of template type {T} on the stored value.
Call canView() to find out whether such a view is supported. If no such view can be created, returns the stored value converted to the template type {T}. Call canConvert() to find out whether a type can be converted. If the value can neither be viewed nor converted, a \l{default-constructed value} will be returned.
Definition at line 515 of file qvariant.h.
References QMetaType::view().
|
protected |
Definition at line 2161 of file qvariant.cpp.
References d, ptr(), QVariant::Private::type(), and QMetaType::view().
|
friend |
Definition at line 632 of file qvariant.h.
|
friend |
If v contains an object of type T
, returns a pointer to the contained object, otherwise returns \nullptr.
The overload taking a mutable v detaches v: When called on a \l{isNull()}{null} v with matching type T
, v will not be null after the call.
These functions are provided for compatibility with {std::variant}.
Definition at line 624 of file qvariant.h.
Returns false
if v1 and v2 are equal; otherwise returns true
.
QVariant uses the equality operator of the type() contained to check for equality.
Variants of different types will always compare as not equal with a few exceptions:
\list
Definition at line 613 of file qvariant.h.
|
friend |
Definition at line 617 of file qvariant.h.
|
related |
Writes a variant p to the stream s.
Definition at line 1427 of file qvariant.cpp.
|
related |
Writes a variant type p to the stream s.
Returns true
if v1 and v2 are equal; otherwise returns false
.
QVariant uses the equality operator of the type() contained to check for equality.
Variants of different types will always compare as not equal with a few exceptions:
\list
The result of the function is not affected by the result of QVariant::isNull, which means that two values can be equal even if one of them is null and another is not.
Definition at line 611 of file qvariant.h.
|
related |
Reads a variant p from the stream s.
\quotation QVariant::load: unknown user type with name QList<int> \endquotation
Definition at line 1415 of file qvariant.cpp.
|
related |
Reads a variant type p in enum representation from the stream s.
|
friend |
Returns the given value converted to the template type {T}.
This function is equivalent to QVariant::value().
Definition at line 746 of file qvariant.h.
|
related |
Returns the given value converted to the template type {T}.
This function is equivalent to QVariant::value().
Definition at line 746 of file qvariant.h.
|
friend |
Definition at line 763 of file qvariant.h.
|
related |
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).
|
related |
|
related |
Synonym for QList<QVariant>.
Definition at line 15 of file qjsonarray.h.
|
related |
Synonym for QMap<QString, QVariant>.
Definition at line 46 of file qcontainerfwd.h.
|
related |
Returns the given value converted to the template type {T}.
This function is equivalent to \l{QVariant::value()}{QVariant::value}<T>(value).
|
protected |
Definition at line 665 of file qvariant.h.
Referenced by QQmlVMEResolvedList::QQmlVMEResolvedList(), QVariant(), ~QVariant(), clear(), QV4::coerce(), compare(), convert(), convert(), data(), detach(), equals(), isDetached(), isNull(), isValid(), load(), QQmlVMEMetaObject::metaCall(), metaType(), QV4::ExecutionEngine::metaTypeFromJS(), operator=(), qtObjectFromJS(), save(), toBool(), toDouble(), toFloat(), toInt(), toLongLong(), toReal(), toUInt(), toULongLong(), typeName(), view(), and QObjectPointerBinding::write().