QT Script - assigned struct in script

  • Hello,

    I'm writing program, that have struct with data (only data). This struct has no Q_OBJECT macro and isn't inherit from QObject.
    Something like this:

    struct DATA2{
         QString beta;
         int b;
    struct DATA{
         QString alfa;
         int a;
         DATA2 d;

    Now I want use script to process this struct and return QString:

        script_engine=new QScriptEngine();
        DATA data;
        QScriptValue arg=script_engine->newQObject(&data);
        QScriptValue val=script_engine->evaluate(script_content);
            WARNING<<"ERROR: "<<val.property("lineNumber").toInteger()<<"  - "<<val.toString();

    Is there a way to do this? Without write getter function for all records in the structure? Script will only read values.

    Thank you

  • Lifetime Qt Champion

    I dont think so.
    It has to be a QObject and use properties.

Log in to reply