I have a tree which is used to store values of different types, e.g. int
, double
, string
or whatever. There is a Base
class which implements the basic tree functionality (children, parents) and a derived class template<class T> class Derived: public Base
, where T
is the type of value to be stored. It has a get function to return the parameters (a template function returning the type T
)
I am doing a user-interface with Qt
and thus need to implement a QAbstractItemModel
in order to view my tree. When subclassing QAbstractItemModel
I need to be able to call the get
function of my Derived
class, but I only have a pointer to an instance of the class (which I get from the QAbstractItemModel
), and don't know its type, therefore I could cast the pointer to Base
but this does not allow me to call the get
function. Is there a way to find the type of my Derived
class form a Base
class pointer?