variant QML Basic Type
variant type is a generic property type. It is obsolete and exists only to support old applications; new applications should use var type properties instead.
A variant type property can hold any of the basic type values:
variant type property can also hold an image or pixmap. A
Clients may explicitly release such a scarce resource by calling the "destroy" method on the
variant type can also hold:
For example, below is an
items array and an
for loops. Individual array values are accessible by index, and individual map values are accessible by key:
While this is a convenient way to store array and map-type values, you must be aware that the
attributes are not QML properties. Rather, the
items property holds an array of values, and
attributes holds a set of key-value pairs.
attributes are not QML objects, changing the values they contain does not trigger property change notifications. If the above example had
onAttributesChanged signal handlers, they would not be called when assigning individual entries in either property. If, however, the
attributes properties themselves were reassigned to different values, then such handlers would be called.
This basic type is provided by the QML language.
See also QML Basic Types.
© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.