Having read the SCXML invoke example I ask myself how this should work if you want to invoke a state machine that was compiled to C++ code using qscxmlc
. I noticed that it is possible to invoke another state machine by using the src
attribute in the invoke
tag. I got this working by setting src
to the filesystem path of an SCXML file. I could however not figure out how to refer to an SCXML file in the Qt resources (using qrc:///...
did not work) or how to invoke a compiled state machine.
Update
I could not find anything in Qt's documentation so I had a look at the sources (version 5.8):
Loading is implemented in qscxmlcompiler.cpp
in QScxmlCompilerPrivate::DefaultLoader::load(..)
(line 2447):
const QUrl url(name);
if (!url.isLocalFile() && !url.isRelative())
errs << QStringLiteral("src attribute is not a local file (%1)").arg(name);
QFileInfo fInfo = url.isLocalFile() ? url.toLocalFile() : name;
#endif // BUILD_QSCXMLC
if (fInfo.isRelative())
fInfo = QFileInfo(QDir(baseDir).filePath(fInfo.filePath()));
// ...
I notice that it uses QUrl and therefore should be able to work with resources I tried using :/mystatemachinefile.scxml
instead of rsc://mystatemachinefile.scxm
and it worked :) This however should be added to the docs IMHO.
I still wonder how you should implement state charts if you want to compile them before they are used, but I guess this is not possible at the moment?