Unsolved Consistency between null QJsonValue and QVariant
-
Suppose to have QJsonValue with a null type and then convert it to QVariant. This QVariant converted has type std::nullptr_t. It's just me or does not exists a way to instantiate a QVariant which match that type?
QJsonValue value{QJsonValue::Null}; QVariant variant = value.toVariant(); qDebug() << value << variant; // QJsonValue(null) QVariant(std::nullptr_t, (nullptr)) qDebug() << variant.isNull() << variant.isValid(); // true true qDebug() << variant.type() << variant.typeName(); // QVariant::std::nullptr_t std::nullptr_t
-
@Moia
I don't understand: you have instantiated aQVariant
with that type, via yourQVariant variant = value.toVariant();
? -
How can I create a QVariant with the same state Variant(std::nullptr_t, (nullptr)) ?
-
@Moia
Like I said, there may be other ways, but you already have done just this with your:QJsonValue value{QJsonValue::Null}; QVariant variant = value.toVariant();
?
-
Maybe @Moia want a method to get that QVariant without a QJsonValue?
By looking into the source code of QJsonValue, you can see that value comes fromQVariant::fromValue(nullptr)