[Development] QVariant container API

Vasily Pupkin shkodindanil.letmework at gmail.com
Mon Apr 1 11:09:27 CEST 2019


I would like to submit a patch. Since it is probably going to break binary
compatibility and is mostly about coding conventions, I would like to have
some feedback before investing time.

The general idea is to create a playground project for automatic
(de)serialization for Qt (not manual, i.e. overriding operators). The only
stopper is container deserialization.
To operate containers without staticaly knowing their types, one should be
able to make conversions from QVariant containing a container to container
of QVariants and vice versa.
Seriazation is quite straightforward via QSequentialIterable and
QAssociativeIterable. But deserialization is currently possible only by
QMetaType::registerConverter. I think, that this is would be so nice to
have an ability to create a container via QVariant from collection of
QVariant instances without a need for custom converters.
QList<QVariant> variantContainer;
QVariant variant(QVariant::fromValue(variantContainer));
QVariant containerVariant(variant.convert(qMetaTypeId<QList<int> >()));

And so I have stumbled into a problem. QSequentialIterable  and
QAssociativeIterable related code is scattered across <qvariant.h> and
<qmetatype.h>. All related conversions are conveyed in templates, instead
I just don't feel, that further
is the way to go.

And so the question is: should I try to refactor sequential and associative
iterators, so templates are used only to staticaly gather information about
containers and conversions are made in qvariant.cpp, where they belong?

It also would be nice to hear, if someone acknowledges this conversion
feature to be of use.

Thanks for reading this far.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20190401/79322755/attachment.html>

More information about the Development mailing list