On 2015-02-18 16:53, Thiago Macieira wrote: > On Wednesday 18 February 2015 12:16:58 Matthew Woehlke wrote: >>> I have not tried QSettings yet, but since it works with QVariant it >>> should >>> work. >> >> Sure, I'd expect it to work, also :-). What I meant was, does it get >> written as an integer, or as a string? > > Neither. > > It's written as @Variant(<QDataStream serialisation of the type goes here>) > where the QDataStream serialisation includes the type's name. It also only > works if you've registered operator<< and operator>> for your type.
enum foo {bar}; QSettings().setValue("foo", bar); Didn't check, but considering I haven't even registered the metatype, I'm pretty sure this writes "foo=0". However, that goes back to my previous point; adding Q_ENUM(foo) is not going to change this, because the value is already converted to numeric when the QVariant is constructed, when I'm doing it this way. If I'm doing QVariant::fromValue<foo>(bar), then presumably I already have my own QDataStreap << and >> operators, and Q_ENUM isn't going to change that either (at least not without me as a developer being very aware of that change, which I think is sufficient). A better question might be if this works: Q_ENUM(foo) // assume same 'foo' as above QSettings().setValue("foo", QVariant::fromValue<foo>(bar).toString()); auto v = QSettings().value("foo"); v.value<foo>(); // does this return foo::bar? -- Matthew _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development