Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 7

Qt-interest Archive, August 2006
QVariant, user pointer


Message 1 in thread

I need to pass a pointer to my "class A" to a method that takes a QVariant.

this works fine:

A *a;
QVariant v = qVariantFromValue(a);

but then how do I get the pointer back? The following doesn't seem to
work (intentionally stupid question):

a = qVariantValue(v);



-- 
 [ signature omitted ] 

Message 2 in thread

have you tried
 
v.value<A*>()
 
it might me a QT 4 syntax (and it might not need the pointer notation) 
 
Scott

________________________________

From: Patrick Stinson [mailto:patrickkidd.lists@xxxxxxxxx]
Sent: Thu 8/31/2006 11:20 AM
To: qt-interest@xxxxxxxxxxxxx
Subject: QVariant, user pointer



I need to pass a pointer to my "class A" to a method that takes a QVariant.

this works fine:

A *a;
QVariant v = qVariantFromValue(a);

but then how do I get the pointer back? The following doesn't seem to
work (intentionally stupid question):

a = qVariantValue(v);



--
 [ signature omitted ] 

Message 3 in thread

I'm not mister template-freak, but:

/usr/local/Trolltech/Qt-4.1.4/lib/QtCore.framework/Headers/qvariant.h:
In function 'int qt_variant_metatype_id(T*) [with T =
ousia::Region*]':
/usr/local/Trolltech/Qt-4.1.4/lib/QtCore.framework/Headers/qvariant.h:624:
  instantiated from 'T qvariant_cast(const QVariant&) [with T =
ousia::Region*]'
/usr/local/Trolltech/Qt-4.1.4/lib/QtCore.framework/Headers/qvariant.h:637:
  instantiated from 'T qVariantValue(const QVariant&) [with T =
ousia::Region*]'
/usr/local/Trolltech/Qt-4.1.4/lib/QtCore.framework/Headers/qvariant.h:280:
  instantiated from 'T QVariant::value() const [with T =
ousia::Region*]'
groupregionbrowser.cpp:63:   instantiated from here
/usr/local/Trolltech/Qt-4.1.4/lib/QtCore.framework/Headers/qvariant.h:393:
error: 'qt_metatype_id' is not a member of
'QMetaTypeId<ousia::Region*>'

On 8/31/06, Scott Aron Bloom <scott@xxxxxxxxxxxx> wrote:
> have you tried
>
> v.value<A*>()
>
> it might me a QT 4 syntax (and it might not need the pointer notation)
>
> Scott
>
> ________________________________
>
> From: Patrick Stinson [mailto:patrickkidd.lists@xxxxxxxxx]
> Sent: Thu 8/31/2006 11:20 AM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: QVariant, user pointer
>
>
>
> I need to pass a pointer to my "class A" to a method that takes a QVariant.
>
> this works fine:
>
> A *a;
> QVariant v = qVariantFromValue(a);
>
> but then how do I get the pointer back? The following doesn't seem to
> work (intentionally stupid question):
>
> a = qVariantValue(v);
>
>
>
> --
> Patrick Kidd Stinson
> http://www.patrickkidd.com/
> http://pkaudio.sourceforge.net/
> http://pksampler.sourceforge.net/
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>
>


-- 
 [ signature omitted ] 

Message 4 in thread

The following works, but I don't like it as much:

QVariant v = qVariantFromValue((void *) a);
a = (A *) v.value<void *>();

On 8/31/06, Patrick Stinson <patrickkidd.lists@xxxxxxxxx> wrote:
> I'm not mister template-freak, but:
>
> /usr/local/Trolltech/Qt-4.1.4/lib/QtCore.framework/Headers/qvariant.h:
> In function 'int qt_variant_metatype_id(T*) [with T =
> ousia::Region*]':
> /usr/local/Trolltech/Qt-4.1.4/lib/QtCore.framework/Headers/qvariant.h:624:
>   instantiated from 'T qvariant_cast(const QVariant&) [with T =
> ousia::Region*]'
> /usr/local/Trolltech/Qt-4.1.4/lib/QtCore.framework/Headers/qvariant.h:637:
>   instantiated from 'T qVariantValue(const QVariant&) [with T =
> ousia::Region*]'
> /usr/local/Trolltech/Qt-4.1.4/lib/QtCore.framework/Headers/qvariant.h:280:
>   instantiated from 'T QVariant::value() const [with T =
> ousia::Region*]'
> groupregionbrowser.cpp:63:   instantiated from here
> /usr/local/Trolltech/Qt-4.1.4/lib/QtCore.framework/Headers/qvariant.h:393:
> error: 'qt_metatype_id' is not a member of
> 'QMetaTypeId<ousia::Region*>'
>
> On 8/31/06, Scott Aron Bloom <scott@xxxxxxxxxxxx> wrote:
> > have you tried
> >
> > v.value<A*>()
> >
> > it might me a QT 4 syntax (and it might not need the pointer notation)
> >
> > Scott
> >
> > ________________________________
> >
> > From: Patrick Stinson [mailto:patrickkidd.lists@xxxxxxxxx]
> > Sent: Thu 8/31/2006 11:20 AM
> > To: qt-interest@xxxxxxxxxxxxx
> > Subject: QVariant, user pointer
> >
> >
> >
> > I need to pass a pointer to my "class A" to a method that takes a QVariant.
> >
> > this works fine:
> >
> > A *a;
> > QVariant v = qVariantFromValue(a);
> >
> > but then how do I get the pointer back? The following doesn't seem to
> > work (intentionally stupid question):
> >
> > a = qVariantValue(v);
> >
> >
> >
> > --
> > Patrick Kidd Stinson
> > http://www.patrickkidd.com/
> > http://pkaudio.sourceforge.net/
> > http://pksampler.sourceforge.net/
> >
> > --
> > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> > List archive and information: http://lists.trolltech.com/qt-interest/
> >
> >
> >
> >
>
>
> --
> Patrick Kidd Stinson
> http://www.patrickkidd.com/
> http://pkaudio.sourceforge.net/
> http://pksampler.sourceforge.net/
>


-- 
 [ signature omitted ]