[Development] QVariant container API

Vasily Pupkin shkodindanil.letmework at gmail.com
Sat Mar 21 13:25:29 CET 2020


Hi.
It has been almost a year since I have raised the topic. A quick recap:
I was playing with serializaion and stumbled upon a problem with container
reflection.
In Qt there is an API to introspect container elements dynamically via the
meta type system.
But there is no way to populate a container.
Jedrzej Nowacki discussed a way to extend QSequentialIterable.
Thiago Macieira expressed a point that QSequentialIterable seems unsuitable
for the task
and will lead to lossy conversions without error reporting.

I took my time and created a proof of concept project.
https://github.com/windymindy/rializer

I want to clarify that I am not pushing any serialization API into Qt.
Everyone can write his own serialization/deserialization library if
necessary.
But I do propose an API for a meta container class. The project is just a
playground for it.
https://github.com/windymindy/rializer/blob/master/sources/metatypesystem/rmetacontainer.h


In my opinion it could be of great use, for example, in QML, QWebChannel or
JSON-RPC 2.0 plugin for QHttpServer.
There is already a feature request for the functionality.
https://bugreports.qt.io/browse/QTBUG-79170

Please, tell if you mind removing QSequentialIterable and
QAssociativeIterable completely in Qt 6
in favour of a QMetaContainer-like class.
And also adding IsContainer flag to QMetaTyle::TypeFlag.

P.S.
Feel free to share any feedback.

I still need to investigate automatic registration. Need to spare some time
to look into /mkspecs/features/metatypes.prf .
I also wonder why std::deque doesn't have built-in support like std::vector
or list.
https://doc.qt.io/qt-5/qmetatype.html#Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE


On Mon, Apr 1, 2019 at 4:10 PM Thiago Macieira <thiago.macieira at intel.com>
wrote:

> But I'm not going to stop you. Make a proof of concept and we may be able
> to
> discuss. Worst case is that we don't add it to QtCore, but it gets
> released
> elsewhere.
>

On Mon, Apr 1, 2019 at 1:33 PM Jedrzej Nowacki <Jedrzej.Nowacki at qt.io>
wrote:

> Sure, try, you can add me to review :-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200321/c52cf09d/attachment.html>


More information about the Development mailing list