QStringList returned from QJSEngine::evaluate() converted to QVariantMap instead of QVariantList?

  • I am playing with the new QJSEngine in Qt 5 and find this a bit odd:

    @QStringList MyQObject::test()
    QStringList list;
    list << "abc" << "xyz";
    return list;

    int main(int argc, char *argv[])

    MyQObject w;

    QJSEngine js;
    QJSValue ww = js.newQObject(&w);
    js.globalObject().setProperty("w", ww);
    QJSValue r = js.evaluate("w.test()");
    QVariant v = r.toVariant();
    qDebug() << v;


    MyQObject::test() is declared as Q_INVOKABLE

    And the output:
    @QVariant(QVariantMap, QMap(("0", QVariant(QString, "abc") ) ( "1" , QVariant(QString, "xyz") ) ) ) @

    I was expecting it to be a QVariantList (or better yet, a QStringList). Is this expected behavior or a bug worth reporting?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.