QStateMachine and SCXML



  • Hello,

    I am using the latest version of the QT SDK and qscxml and am trying to create a custom invoker with some sample code from the web page "Using SCXML files in Qt". The documentation appears to be out of date. The code does not compile (see below).

    Could someone point me in the right direction?

    Thanks,

    Eric

    @
    #include <QtScriptedStateMachine>

     class MyInvoker : public QtSsmInvoker
     {
         Q_OBJECT
         public:
             MyInvoker(QtScriptedEvent* ievent, QtScriptedStateMachine* p) : QtSsmInvoker(ievent,p),menu(0)
             {
             }
             static void initInvokerFactory(QtScriptedStateMachine* machine)
             {
                 machine->scriptEngine()->globalObject().setProperty("some-name",someValue);
             }
             static bool isTypeSupported (const QString & s) { return s== "my-type"; }
         public Q_SLOTS:
             void activate ()
             {
                 doSomeStuff ();
             }
     };
    

    ...
    static QSsmAutoInvokerFactory<MyInvoker> _s_factory;
    myScriptedStateMachine->registerInvoker(&_s_factory);
    @

    [Edit: Added @ code tags. Also split into a new thread. -- mlong]



  • Update: Solved this problem by emulating the default invoker.

    Another question:

    I would like to ask how can I access an qscxml global from either my main or from the invoker?

    They are created as private globals as follows
    @
    QScriptValue glob = pvt->scriptEng->globalObject();
    glob.setProperty("_data",pvt->scriptEng->newObject());
    glob.setProperty("_global",pvt->scriptEng->globalObject());
    @

    Thanks,

    Eric

    [Edit: Added @ tags -- mlong]


  • Moderators

    Hi, Eric, welcome to Devnet!

    Please be sure to wrap your code snippets in @ tags for formatting. Also, please open new threads for additional topics/questions. Thanks, and welcome again!


Log in to reply
 

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