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
qRegisterMetaType
for some specific template class, e.g.Range<quint32>
. Everything looked like OK, but in QML all methods ofRange
were inaccessible (returned undefined value, e.g.). So I have tried to register it additionally withqmlRegisterType
and found that staticMetaObject is not Range<quint32> member. As far I understand that's because of myRange
type is notQObject
(correct my if I wrong).- Obviously, my second attempt was creating my
Range
asQObject
derived class, but I faced big problem much more earlier:QObject
does 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