Reputation: 10683
I'm trying to replace all dynamicCasts in my code with QT's objectCast. But I've run into a bit of a snag. Here's the hierarchy of my objects:
class ABase : public QObject
class IAbility; // Registered as Qt Interface
class ISize; // Registered as Qt Interface
class Derived : public ABase, public IAbility, public ISize; // Uses Q_INTERFACES
Using objectCast I can convert a Derived to a ISize or IAbility. However, in one point of my code I want to perform the following conversion: Derived->ISize->IAbility. That last cast is where I get an error. Since IAbility does not relate to ISize in any way, that could cause a problem. I could do a dynamic cast at this point, but I'd rather not.
Upvotes: 1
Views: 622
Reputation: 8204
As I see it you have three options:
I would go for option 3, simply because it's the least forced solution, abstraction-wise.
Upvotes: 3