const qobject_cast for interfaces
General and Desktop
1
Posts
1
Posters
735
Views
1
Watching
-
wrote on 24 Jul 2015, 13:16 last edited by Asperamanca
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?
1/1