QVariant::default() yields an undefined value in QML, but in many places a null value is more suited. Add QVariant::null() function to achieve that. The test added help distinguishing this.
I would have used QVariant(nullptr) instead, but that doesn't seem to work well with the type system in Qt5. The QJsonValue().toVariant() is the next best option - and makes sense, since a JSON can also have an explicit null value.
QVariant::default()
yields anundefined
value in QML, but in many places anull
value is more suited. AddQVariant::null()
function to achieve that. The test added help distinguishing this.I would have used
QVariant(nullptr)
instead, but that doesn't seem to work well with the type system in Qt5. TheQJsonValue().toVariant()
is the next best option - and makes sense, since a JSON can also have an explicitnull
value.