Important: Please read the Qt Code of Conduct -

Expose enum to QScriptEngine

  • I've searched the docs and google but am unable to find an example of how this is done. I am exposing the ability to create new a new object like this:

    QScriptValue ctor = _scriptEngine->newFunction(ScriptFile::createNew);
    v = _scriptEngine->newQMetaObject(&QObject::staticMetaObject, ctor);
    _scriptEngine->globalObject().setProperty("File", v);

    And I found this "Values for enums declared with Q_ENUMS are not available as properties of individual wrapper objects; rather, they are properties of the QMetaObject wrapper object that can be created with QScriptEngine::newQMetaObject()." "here":

    But I am still unsure how to do it. Lets say my "File" object has the enum File::Count with values File::ONE and File::TWO, how would I go about exposing those?


Log in to reply