Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.3.0
-
None
-
Qt 5.3.0
MSVC 2013
Windows 8.1
Description
I have a list of objects with properties, constructed by parsing a JSON string. Some of these properties are null. This list of object is then used as the model of a ListView component.
The problem is, any 'null' property is converted to a QVariant(void*) inside the list model, and there doesn't seem to be any way of knowing that this QVariant(void*) is a null value.
ListView { Component.onCompleted: { var result = [{'test': null}]; print("original value:", result[0].test); model = result; print("in model:", model[0].test); } delegate: Item { Component.onCompleted: { var t = modelData.test; print("in delegate:", t); print(t === null, t === undefined, t === false, t === ""); } } }
qml: original value: null qml: in delegate: QVariant(void*) qml: false false false false qml: in model: QVariant(void*)
The real context: the JSON string is returned by a web service, and the null values are supposed to be strings. These strings are assigned to Text components. And because of this problem, I have no way of handling null strings correctly (without QML errors).
Attachments
Issue Links
- replaces
-
QTBUG-26951 QJSValue has a different representation of NULL to QV8Engine
- Closed