[Interest] Why no T& QVariant::value()?

Jason H jhihn at gmx.com
Mon Jun 4 23:04:29 CEST 2018


> Sent: Monday, June 04, 2018 at 4:46 PM
> From: "Allan Sandfeld Jensen" <kde at carewolf.com>
> To: interest at qt-project.org
> Subject: Re: [Interest] Why no T& QVariant::value()?
>
> On Montag, 4. Juni 2018 09:00:28 CEST Giuseppe D'Angelo wrote:
> > Il 23/05/2018 16:16, Jason H ha scritto:
> > > Really wishing this function existed. Can someone explain why it doesnt'
> > > exist?
> > Because QVariant (as well as most Qt APIs) has wide contracts; combined
> > with the policy of not using exceptions, that makes such a function
> > impossible to implement.
> > 
> Actually it probably could be, but it would be ugly, we already do something 
> similar for QJsonValues, though on a more limited scope. And depending on what 
> you want from it, it might need to be type strong and templated for a specific 
> type T.


Thanks everyone.

So as a sanity check, what is the best way to have a nestable application database of things that QVariant can hold and be trivially serialized?
something like:
Something map;
map["a"]=QRect(1,1, 45,45);
map["b"]=Something();
map["b"]["x"]=7;
map["b"]["y"]=8;
map["b"]["x"]=0; // change ["b"]["x"]

ds << map;
ds >> map;

Really, that's all I'm trying to do. I just want a easy-peasy database that isn't relational.




More information about the Interest mailing list