woboq / qmetaobject-rs

Integrate Qml and Rust by building the QMetaObject at compile time.
MIT License
647 stars 89 forks source link

Add null QVariant constructor #312

Open direc85 opened 3 months ago

direc85 commented 3 months ago

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.