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

Qt-interest Archive, January 2007
Some help with cast to QPointer wished for.


Message 1 in thread

Hi List

I have a definition like this:
QPointer<svNodeChain*> hostChain;  in a class named svNode



And I try to assign to this in another class like so:

void* temp = this;

nodens->hostChain = temp;

Where nodens is of type svNode* and hostChain is as above

but I keep getting errors of this kind:

Error 1 error C2679: binary '=' : no operator found which takes a right-hand operand of type 'void *' (or there is no acceptable conversion) c:\RAS\ver_0.1\Ras_Application\svNodeChain.cpp 48 


I have tried const_cast<svNodeChain> and reinterpret_cast<svNodeChain*> and a lot of old c hacks but I cant seem to make

the compiler accept that one pointe just should be treated as another kind of pointer. Do anyone spot the error ?



/Ulf Rosvall





Message 2 in thread

Yes I am aware of that and svNodeChain does inherit QObject.

/Ulf

Message 3 in thread

Ulf Rosvall schrieb:
> QPointer<svNodeChain*> hostChain;  in a class named svNode
> 
> void* temp = this;
> nodens->hostChain = temp;
> 
> Error 1 error C2679: binary '=' : no operator found which takes a 
> right-hand operand of type 'void *' (or there is no acceptable 
> conversion) c:\RAS\ver_0.1\Ras_Application\svNodeChain.cpp 48 
> 
> I have tried const_cast<svNodeChain> and reinterpret_cast<svNodeChain*> 
> and a lot of old c hacks but I cant seem to make
> 
> the compiler accept that one pointe just should be treated as another 
> kind of pointer. Do anyone spot the error ?


Take a look into the docs: No need to specify the type as pointer, 
QPointer<svNodeChain> should do. If that doesn't help: What about 
qobject_cast? Or declaring temp with the correct type right away?

Martin
-- 
 [ signature omitted ]