[Qt-interest] QVariant is great, make it better
Mildred Ki'Lya
ml.mildred593 at gmail.com
Wed Jul 8 12:38:07 CEST 2009
Hi,
I use lots and lots of QVariant, and I'll have to use user defined
QVariant types.
Now, I would like to suggest a new feature that could be added at some
point in the future: integrate user QVariants with the others.
Say for example I create a value representing an IPv4 address, The class
could be like:
class IPv4 {
unsigned char a, b, c, d;
...
};
Q_DECLARE_METATYPE(IPv4)
It would be great if when I had an IPv4 QVariant, I could just write
variant.toString() and have the pointed notation for the IP address.
Like 127.0.0.1
It would also be great that given a string QVariant, the
variant.value<IPv4>() would convert the string to an IP address.
I think it would be really great.
The way I think it could be done would be using meta methods. For
example there would be a method that would return a QVariant of a
desired type. And a method that would convert a QVariant into the
targetted type.
For example I would have:
QVariant IPv4::qvariantToType(QVariant::Type t); // convert this to a
QVariant of type t
QVariant IPv4::qvariantFromValue(QVariant origin); // convert origin to
an IPv4 QVariant
Well, that could be done outside the QVariant class, but it would be
really great I think if there was some functionnality like this.
Mildred
--
Mildred Ki'Lya
╭───────── mildred593@online.fr ──────────
│ Jabber, GoogleTalk: <mildred at jabber.fr>
│ Website: <http://ki.lya.online.fr> GPG ID: 9A7D 2E2B
│ Fingerprint: 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 9A7D 2E2B
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090708/3582d63d/attachment.bin
More information about the Qt-interest-old
mailing list