Details
-
Bug
-
Status: Reported
-
P3: Somewhat important
-
Resolution: Unresolved
-
6.4
Description
Repro: here the following code gives a QVariantMap of QVariants which hold doubles, which is incredibly wasteful. In addition, since it is lexicographically sorted, the order will be 0, 1, 10, 11, 12, ..., 2, 20, 21, ...
#include <QCoreApplication> #include <QDebug> #include <QJSEngine> int main(int argc, char *argv[]) { qputenv("QT_ASSUME_STDERR_HAS_CONSOLE", "1"); QCoreApplication a(argc, argv); QJSEngine e; auto res = e.evaluate(R"_( let arr = new Float64Array(15); for(let i = 0; i < 15; i++) arr[i] = i; arr; )_"); qDebug() << res.toVariant(); /* Prints: QVariant(QVariantMap, QMap(("0", QVariant(double, 0))("1", QVariant(double, 1))("10", QVariant(double, 10))("11", QVariant(double, 11))("12", QVariant(double, 12))("13", QVariant(double, 13))("14", QVariant(double, 14))("2", QVariant(double, 2))("3", QVariant(double, 3))("4", QVariant(double, 4))("5", QVariant(double, 5))("6", QVariant(double, 6))("7", QVariant(double, 7))("8", QVariant(double, 8))("9", QVariant(double, 9)))) */ }
Is there any way to make this return at least a list instead of a map? The ideal would be to get a QVector<T> or even more ideally a view type such as std::span<T> if one takes care of keeping the QSJValue alive while work is being done with it...
e.g. I'd expect
qjsvalue_cast<QVector<double>>(res);
to at least give something given a Float64Array