How to cast QPointer<T> to QPointer<childT>
Hi there,
i have a small problem while casting from QPointer<T> to QPointer<ChildT>
I tried this.
QPointer<T> tObject=new T();
//QPointer<ChildT> childtObject=(QPointer<T>)tObjec;// this does not work;
QPointer<ChildT> childtObject=(ChildT*)(T*)tObjec;// this work;
Re: How to cast QPointer<T> to QPointer<childT>
Re: How to cast QPointer<T> to QPointer<childT>
do you mean qobject_cast<childT> thanks for the fast answer
Re: How to cast QPointer<T> to QPointer<childT>
Since QPointer is a "normal" pointer at all you also could use
Code:
QPointer<T> tObject = new T();
QPointer<ChildT> childtObject = (ChildT*) tObjec.data();
Re: How to cast QPointer<T> to QPointer<childT>
to cast to the parentclass pointer and then to child class pointer is correct:
QPointer<T> tObject=new T();
QPointer<ChildT> childtObject=(ChildT*)(T*)tObjec;