How to register types like QList<quint64> in QJSEngine?

584 views Asked by At

I use scripting in my Qt-app with the QJSEngine. One of my C++ functions returns QList<quint64> type, and I need to call it from javascript. It's called with no errors. However, it returns QVariant(QList<qulonglong>) instead of expected list of integers. Another function which is defined to return QList<int> in C++ works fine from javascript, returning the list of integers. I've looked through the docs of QJSEngine and QJSValue, and found no hints for solving this issue. P.S. the quint64 itself works also fine - it's just the list of them which does not work.

1

There are 1 answers

1
fonZ On

You should use QVariantList instead. QVariant supports qlonglong and qulonglong which are the same as qint64 and quint64.

QList<qlonglong> list;

or convert:

QVariant v(list);
QVariantList vlist = v.toList();