Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QJSEngine evaluate giving a syntax error when script source contains class keywork



  • I'm looking at maintaining some code making use of QJSEngine to evaluate some javascript code which before it is executed.

    The changes I've been making to the javascript files required me to add is several java script classes to the source but the QJSEngine evaluate is now reporting a sytax error, with the line number corresponding to my declaration of the class. Below is an example of what I have:

    'use strict';
    
    function MyCode() {
    ....
    }
    
    MyCode.prototype.run = function () {
       var myVar = new MyClass();
       myVar.docDoSomething();
    }
    
    class MyClass {
    ...
    }
    
    

    The code js code before did not use classes and evaluated without issue. Is this simply a restriction of QJSEnjine and I'll need to rethink my strategy for the javascript code?

    Thanks.

    Using QT 5.6.2


Log in to reply