CSmith
7th May 2012, 15:08
Hi all,
This is my first post and early experience with Qt so appologies if this is answered elsewhere but i can not find it.
Here is an example of my problem.
I have base class 'Fruit' and several derived classes let's say 'Apple' and Bannana'
I want to store these in a container, for example a QMap.
So i have created a QMap of Fruits.
I know if i was writting in c# for example i could call the equivelant of typename or typeid on each item and the cast them back to 'Apple' or 'Bannana' when i read them out.
However it seems here i have lost all of the properties of Apple and Bannana and am left with just 'Fruit's.
If i call typename on each item it always returns 'Fruit'
Am i missing something or can i not create a list of derived classes by creating a list of the base class?
Hope this makes sense.
Thanks in advance. :)
This is my first post and early experience with Qt so appologies if this is answered elsewhere but i can not find it.
Here is an example of my problem.
I have base class 'Fruit' and several derived classes let's say 'Apple' and Bannana'
I want to store these in a container, for example a QMap.
So i have created a QMap of Fruits.
I know if i was writting in c# for example i could call the equivelant of typename or typeid on each item and the cast them back to 'Apple' or 'Bannana' when i read them out.
However it seems here i have lost all of the properties of Apple and Bannana and am left with just 'Fruit's.
If i call typename on each item it always returns 'Fruit'
Am i missing something or can i not create a list of derived classes by creating a list of the base class?
Hope this makes sense.
Thanks in advance. :)