[Interest] QT SCXML: How to access Event parameter from State?
Jonathan Fan
jonathan.fan at gmail.com
Fri Mar 16 21:38:43 CET 2018
Thanks Ulf. I think that is exactly what we need.
I tried out the following. but I was having some trouble accessing the
pointer to the dataModel. Am I on the right track?
*SCXML:*
<scxml ... datamodel="cplusplus:LionDataModel:liondatamodel.h" ... >
*liondatamodel.h:*
#include "qscxmlcppdatamodel.h"
class LionDataModel: public QScxmlCppDataModel
{
Q_OBJECT
Q_SCXML_DATAMODEL
};
*C++:*
stateMachine->connectToState("state1", [this](bool active) {
QScxmlDataModel* dataModel = stateMachine->dataModel(); //Returns a
null pointer
QScxmlCppDataModel* cppDataModel =
static_cast<QScxmlCppDataModel*>(dataModel);
QScxmlEvent event = cppDataModel->scxmlEvent();
QVariant data = event.data();
qDebug() << "event.data()" << data;
});
Best,
Jonathan
On Fri, Mar 16, 2018 at 10:38 AM, Ulf Hermann <ulf.hermann at qt.io> wrote:
> > In the example above, how would we get access to Event parameter for
> "state1" and "state5"?
>
> You can access the event currently being processed via the data model. The
> EcmaScript data model has a readonly property "_event" and the C++ data
> model has a method scxmlEvent(). The null data model doesn't handle events,
> so without a data model, you can't access them.
>
> br,
> Ulf
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180316/0443e171/attachment.html>
More information about the Interest
mailing list