QScxmlCompiler Class

QScxmlCompiler 类是 SCXML 文件的编译器。更多

头文件: #include <QScxmlCompiler>
CMake.QScxmlCompiler find_package(Qt6 REQUIRED COMPONENTS Scxml)
target_link_libraries(mytarget PRIVATE Qt6::Scxml)
qmake: QT += scxml

公共类型

class Loader

公共函数

QScxmlCompiler(QXmlStreamReader *reader)
~QScxmlCompiler()
QScxmlStateMachine *compile()
QList<QScxmlError> errors() const
QString fileName() const
QScxmlCompiler::Loader *loader() const
void setFileName(const QString &fileName)
void setLoader(QScxmlCompiler::Loader *newLoader)

详细说明

解析SCXML文件,并为解析成功的 SCXML 文件动态实例化状态机。如果解析失败,新的状态机将无法启动。所有错误都会通过QScxmlStateMachine::parseErrors() 返回。

要加载 SCXML 文件,应使用QScxmlStateMachine::fromFileQScxmlStateMachine::fromData 。只有当编译器需要使用自定义的QScxmlCompiler::Loader 时,才需要直接使用 QScxmlCompiler。

成员函数文档

QScxmlCompiler::QScxmlCompiler(QXmlStreamReader *reader)

为指定的reader 创建新的 SCXML 编译器。

[noexcept] QScxmlCompiler::~QScxmlCompiler()

销毁 SCXML 编译器。

QScxmlStateMachine *QScxmlCompiler::compile()

解析 SCXML 文件并创建新的状态机。

如果解析成功,可以初始化并启动返回的状态机。如果解析失败,QScxmlStateMachine::parseErrors() 可用于获取错误列表。

QList<QScxmlError> QScxmlCompiler::errors() const

返回解析错误列表。

QString QScxmlCompiler::fileName() const

返回与当前输入相关的文件名。

另请参见 setFileName()。

QScxmlCompiler::Loader *QScxmlCompiler::loader() const

返回当前用于为 SCXML 编译器解析和加载 URI 的加载器。

另请参阅 setLoader()。

void QScxmlCompiler::setFileName(const QString &fileName)

将当前输入的文件名设置为fileName

文件名用于错误报告和解析相对路径 URI。

另请参阅 fileName() 。

void QScxmlCompiler::setLoader(QScxmlCompiler::Loader *newLoader)

设置用于 SCXML 编译器解析和加载 URI 的newLoader

另请参阅 loader().

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.