[Qt-interest] Re : Store a QVariant in a QVariant
BOUCARD Olivier
boucard_olivier at yahoo.fr
Mon Sep 19 18:48:07 CEST 2011
Thank you, Thiagoand Giuseppe. It works fine.
>________________________________
>De : Giuseppe D'Angelo <dangelog at gmail.com>
>À : BOUCARD Olivier <boucard_olivier at yahoo.fr>
>Cc : Qt-interest Nokia <qt-interest at qt.nokia.com>
>Envoyé le : Lundi 19 Septembre 2011 18h36
>Objet : Re: [Qt-interest] Store a QVariant in a QVariant
>
>On Mon, Sep 19, 2011 at 5:52 PM, BOUCARD Olivier
><boucard_olivier at yahoo.fr> wrote:
>> Hi all,
>> Basically, what I want to achieve its to store a QVariant A, which stores a
>> value of type X, in a QVariant B in way that B.typeName() return "QVariant"
>> and not "X".
>> I do not know if it is feasible. I try to force the type using
>> QVariant::fromValue but it does not work.
>
>qVariantFromValue has a template specialization for that case...
>http://qt.gitorious.org/qt/qt/blobs/4.7/src/corelib/kernel/qvariant.h#line454
>
>QVariant B(QMetaType::QVariant, &A); ?
>--
>Giuseppe D'Angelo
>
>
>
>________________________________
>De : Thiago Macieira <thiago at kde.org>
>À : BOUCARD Olivier <boucard_olivier at yahoo.fr>
>Envoyé le : Lundi 19 Septembre 2011 18h30
>Objet : Re: [Qt-interest] Store a QVariant in a QVariant
>
>On Monday, 19 de September de 2011 16:52:19 BOUCARD Olivier wrote:
>> Hi all,
>>
>> Basically, what I want to achieve its to store a QVariant A, which stores a
>> value of type X, in a QVariant B in way that B.typeName() return "QVariant"
>> and not "X". I do not know if it is feasible. I try to force the type using
>> QVariant::fromValue but it does not work.
>
>QVariant::fromValue is written such that it copies a variant, instead of
>embedding it.
>
>To force it, you have to do:
> QVariant v(qMetaTypeId<QVariant>(), &origVariant);
>
>--
>Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel Open Source Technology Center
> PGP/GPG: 0x6EF45358; fingerprint:
> E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110919/1e6774f1/attachment.html
More information about the Qt-interest-old
mailing list