Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
4.7.0
-
None
-
8217da65cbe44261a83418017be311bb1a62725d
Description
The section "Extending types from QML" (http://qt.nokia.com/doc/4.7-snapshot/qml-extending-types.html) should be extended to document the "default" default value per type .
Qml seems to have decent default values for some of the built-in types. E.g. if you have a dynamic property declared as "property bool b", and do not assign it an explicit value, b will be 'false'. I tried to find out about the default values used by this JavaScript snippet:
import Qt 4.6 Rectangle { width: 200 height: 200 property int i property bool b property double d property real r property string s property url u property color c property date dt property var v MouseArea { anchors.fill:parent onClicked: { print("Values\n"); print("int: " + i); print("bool: " + b); print("double: " + d); print("real: " + r); print("string: "+ s); print("url: " + u); print("color: " + c); print("date: " + dt); print("var: " + v); } } }
which prints
Values int: 0 bool: 0 double: 0 real: 0 string: url: color: #000000 date: Invalid Date var: undefined
This means also that you can bind to all variables above, except for date and var, which result in runtime warnings:
[...] Unable to assign QDateTime to QDate [...] Unable to assign [undefined] to QVariant
Can this be maybe added to the documentation?