const qobject_cast for interfaces



  • I like to use Q_DECLARE_INTERFACE, because it allows me to use qobject_cast for these interfaces (provided the implementation has the Q_INTERFACES makro)

    All works well, until I try to cast a const instance.

    So this works:
    ISomeInterface* pInterface = qobject_cast<ISomeInterface*>(pSomeObject);

    And this doesn't:
    const ISomeInterface* pInterface = qobject_cast<const ISomeInterface*>(pSomeObject);

    Error message is:
    'const class ISomeInterface' has no member named 'qt_check_for_QOBJECT_macro'
    'const class ISomeInterface' has no member named 'qt_check_for_QOBJECT_macro'

    Any ideas?


Log in to reply
 

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