[Qt-interest] QSharedPointer cast syntax question

Felix Nairz qt.felix.nairz at gmail.com
Fri Jan 22 15:39:21 CET 2010


Hi,

it's definitely a template-noob question but I can't get a 
QSharedPointer cast to work. The compiler keeps complaining...

I have got a function taking a Parameter from a base-class:

void function( QSharedPointer<BaseType> var)

In reality the QSharedPointer is holding a type derived from BaseType. I 
want to downcast the shared pointer to the type of the derived class. I 
have tried something like this:
void function( QSharedPointer<BaseType> var) {
     QSharedPointer<DerivedType> test( qSharedPointerCast(var) );
}
and a variety of other syntax stuff I tried to solve the issue. 
Unfortunately I can't get it working.

Could anybody be so kind to point out how I can do that?

Thanks for your help,
Felix




More information about the Qt-interest-old mailing list