Template Class and QML
-
Hello all!
I did some steps in my investigations, but have faces with several problems (some of them I solved, some moved me to another way). But I have decided to wonder, about possibility of my idea. Can I create template class that can be used in QML?What I have tried:
- I inherited from
QPair<T, P>and create my own
structure Range<T>: public QPair<T, T> {}I have defined constructors, inner logic and so on. I have also registered my type with
qRegisterMetaTypefor some specific template class, e.g.Range<quint32>. Everything looked like OK, but in QML all methods ofRangewere inaccessible (returned undefined value, e.g.). So I have tried to register it additionally withqmlRegisterTypeand found that staticMetaObject is not Range<quint32> member. As far I understand that's because of myRangetype is notQObject(correct my if I wrong).- Obviously, my second attempt was creating my
RangeasQObjectderived class, but I faced big problem much more earlier:QObjectdoes not support template.
So my question is: can I create my own template class that can be used in QML? For my example above I wanted to use my own methods
T lower() const {return QPair<T, T>::first;} T upper() const {return QPart<T, T>::second;} - I inherited from