[Qt5-feedback] QVariant::toString() and custom types
Konrad Rosenbaum
konrad at silmor.de
Fri Jul 15 17:13:57 CEST 2011
Hi,
On Thu, July 14, 2011 13:18, Jerome Vizcaino wrote:
> I use QVariant a lot in Qt4 to store native but also custom types.
> One thing I find a bit annoying is that there is no way to "extend" the
> toString() QVariant functionnality.
>
> How about adding some sort of operator (à la QDataStream) that custom
> types
> could provide to help QVariant convert to/from string ?
>
> This would be really convienent in order to easily print QVariant without
> actually knowing if it's custom or native content.
I have found myself wanting this feature as well. However, I can't think
of a way to implement this without adding more requirements on classes
that are compatible with QVariant.
I.e. it should be done so that classes that cannot be transformed to
QString (yet) are still storable in QVariant. This seems to require a lot
of dark magic... ...any ideas?
Konrad
More information about the Qt5-feedback
mailing list