From what I understand, to make a property an array in QML you must specify it as the type variant
or var
:
property var myArray:[]
And this appears to be exactly the same as:
property variant myArray:[]
Is this true?
From what I understand, to make a property an array in QML you must specify it as the type variant
or var
:
property var myArray:[]
And this appears to be exactly the same as:
property variant myArray:[]
Is this true?
This is not a completely new answer, but contains additional information about the answer provided by @Tim Meyer, based on my own experience:
property variant
has to be used otherwise QML parsing errors will be produced.property variant
orproperty var
can be used. But the latter one is recommended, as the former one is being deprecated.Qt 4
property variant
or Qt 5property var
may be used for QML array or list declaration/definition. But if the type and unchangeable content ofmyArray
are known in advance,property list<Type>
can also be used. For example:property list<
Item
> myArray: [ Item {}, Item {} ]According to the Qt 5.0 variant documentation:
So yes, it is the same, but you should always stick to
var
(unless you got an earlier version which does not support that yet).