[Solved] Cannot cast QObject subclass to QObject



  • I have a class that derives from QGraphicsWidget, and thereby from QObject.

    When attempting to cast a pointer to that class to a QObject pointer, I get a compiler error in VS 2010:

    error C2440: 'static_cast' : cannot convert from 'HIPASE::CTpic_GraphicsDisplayRootElementWidget *' to 'QObject *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    My class contains the Q_OBJECT macro, and public QGraphicsWidget is first in the list of base classes.

    Any ideas?



  • Error was: I only forward-declared the class, didn't include the header


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.