Polymorphic QSharedPointer



  • 2 Answer(s)

    The Polymorphic QSharedPointer:

    Click this link. qSharedPointerCast():

    QSharedPointer <Switch> mySwitchTest= qSharedPointerCast<Switch>(myState);
    
    

    By  calling the  staticCast() on  smart pointer:

    QSharedPointer <Switch> mySwitchTest= myState.staticCast<Switch>();
    
    

    The equal of the version isstatic_cast on basic pointers.

     

    Answered on January 11, 2019.
    Add Comment

    The initialized answer is:

    Here,the dynamic cast use the qSharedPointerDynamicCast:

    class Derived : public Base { ... };
    QSharedPointer<Base> base...
    QSharedPointer<Derived> derived = qSharedPointerDynamicCast<Derived>( base );
    

    The   static_cast  is also an equivalents for  qobject_cast and const_cast.

    Answered on January 11, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.