本页内容

QScxmlCompiler Class

QScxmlCompiler 类是一个用于编译 SCXML 文件的编译器。更多内容...

标题: #include <QScxmlCompiler>
CMake: 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::fromFile 或QScxmlStateMachine::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)

将newLoader 设置为 SCXML 编译器用于解析和加载 URI 的文件。

另请参阅 loader()。

© 2026 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.