Register QMetaType with specific ID?
-
Hi all,
I have a custom struct that I want to use as a QVariant, convert to a string which gets saved in a database, from which it should be restored from the saved string. In order to restore the QVariant with the correct type, I also save the type id in the database.
Right now I register it with
int vVariantRangeID = qRegisterMetaType<AFilterItem::VariantRange>();
and supposedly the ID will always be the same as long as I have the same number and order of qRegisterMetaTypes starting with 65536, but I'd like to be sure and define a specific ID, so that for example it will always be 65600. Is that possible?
Thanks.
Best wishes,
Angela -
If you have a QVariant you can use a QDataStream on a QByteArray to serialize/deserialize it.
Note that internally it uses the type name and not the type id to differentiate between types (for user types).
-
If you have a QVariant you can use a QDataStream on a QByteArray to serialize/deserialize it.
Note that internally it uses the type name and not the type id to differentiate between types (for user types).
@GrecKo Yes, but I'd like it to be somewhat readable and manually editable.
But I suppose I could save the type name instead of the id. Thanks.