Qt5.5 QJSEngine 很简单的一段js加法计算问题



  • QJSEngine jsEngine;
    QJSValue value = jsEngine.evaluate(QLatin1String("1 + 2"));
    qDebug() << value.toString(); // 输出 3
    

    同样的代码改为8进制就报语法错误:

    QJSEngine jsEngine;
    QJSValue value = jsEngine.evaluate(QLatin1String("01 + 02"));
    qDebug() << value.toString(); // 输出 SyntaxError: Syntax error
    

    不知为何,有朋友知道吗,感谢!


Log in to reply
 

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