When QGraphicsItem meets heritage
Hi Qt community ,
I wouldn't call it an issue but ,
I have a subclassed QGraphicsItem that's inherited by 3 classes .
I want the 3 inheriting classes to have in common the same advance() method ( without copy pasting the code in the advance() method of each one of them ofcourse :b) .
I tried writing my code in the advance() method of the mother class but it didn't work .
Any ideas ?
I'll be grateful ;)
Maybe you should talk about how the 3 classes inherit the parent or how you use the advance() method
I think it will be more clear on the problem and others can help you
Sorry for bad english
And it would help to know what did not work, else we can only guess.
In addition what other said already, you may be talking about GraphicsItem->A. A->B, A->C, A-D. Hope this is the inheritance you are talking about. This should go with Simple C++ method called advance() in your class A. you can provide the default implementation in A. Or you can make it virtual in A and implement it. If you want change the implementation change in B, C and D.
Yes , the heritage is like you said : A-> B , A-> C , A-> D .
And i mentionned that writing the code i want to be executed by the three classes in the mother Class "A" doesn't work .
But since , u confirmed that , does the problem exist because I didn't declare the mother advance() method virtual ?
Best regards :)
Yep, it's fixed.