Unable to save a list of object with the Settings QML type
-
Hello, I'm trying to save the value of a variable, which is a list of object:
let x = [ { "text": "hello" }, { "text": "world" } ]
so I try to save it using the Settings QML type:
Settings{ id: data }
data.setValue("myKey", x)
but this throws this error:
QDataStream::operator<< was to save a non-trivial QJSValue. This is not supported anymore, please stream a QVariant instead.
what does it mean? Do I need c++ to save this type of data? Isn't possible to convert my array to something like a string or something, save it, and then when reading the value reverting to the original array?
saving integers, doubles and strings works well
I'm using Qt 6.4.1 on Fedora Linux 37 KDE Spin, compiling for Desktop
thank you in advance!
-
@tubbadu
These are fine to use in JavaScript. Whether that is optimal here I don't know.Going back to the original error, is it telling you that it wanted you to go:
data.setValue("myKey", x.toVariant())
-
hello, i wonder why toVariant() dont work for me,toVariant xxx is not a function