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":http://doc.qt.nokia.com/latest/scripting.html#enum-values

    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?

    Thanks.


Log in to reply
 

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