QScxmlDataModel Class
QScxmlDataModel 类是Qt SCXML 状态机的数据模型基类。更多
Header: | #include <QScxmlDataModel> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Scxml) target_link_libraries(mytarget PRIVATE Qt6::Scxml) |
qmake: | QT += scxml |
继承: | QObject |
继承于 |
公共类型
class | ForeachLoopBody |
属性
- stateMachine : QScxmlStateMachine*
公共功能
QScxmlDataModel(QObject *parent = nullptr) | |
QBindable<QScxmlStateMachine *> | bindableStateMachine() |
virtual void | evaluateAssignment(QScxmlExecutableContent::EvaluatorId id, bool *ok) = 0 |
virtual void | evaluateForeach(QScxmlExecutableContent::EvaluatorId id, bool *ok, QScxmlDataModel::ForeachLoopBody *body) = 0 |
virtual void | evaluateInitialization(QScxmlExecutableContent::EvaluatorId id, bool *ok) = 0 |
virtual bool | evaluateToBool(QScxmlExecutableContent::EvaluatorId id, bool *ok) = 0 |
virtual QString | evaluateToString(QScxmlExecutableContent::EvaluatorId id, bool *ok) = 0 |
virtual QVariant | evaluateToVariant(QScxmlExecutableContent::EvaluatorId id, bool *ok) = 0 |
virtual void | evaluateToVoid(QScxmlExecutableContent::EvaluatorId id, bool *ok) = 0 |
virtual bool | hasScxmlProperty(const QString &name) const = 0 |
virtual QVariant | scxmlProperty(const QString &name) const = 0 |
virtual void | setScxmlEvent(const QScxmlEvent &event) = 0 |
virtual bool | setScxmlProperty(const QString &name, const QVariant &value, const QString &context) = 0 |
void | setStateMachine(QScxmlStateMachine *stateMachine) |
virtual bool | setup(const QVariantMap &initialDataValues) = 0 |
QScxmlStateMachine * | stateMachine() const |
信号
void | stateMachineChanged(QScxmlStateMachine *stateMachine) |
静态公共成员
QScxmlDataModel * | createScxmlDataModel(const QString &pluginKey) |
保护函数
QScxmlDataModel(QScxmlDataModelPrivate &dd, QObject *parent = nullptr) |
另请参阅 QScxmlStateMachine,QScxmlCppDataModel, 和QScxmlNullDataModel 。
属性文档
[bindable]
stateMachine : QScxmlStateMachine*
注意: 此属性支持QProperty 绑定。
此属性保存此数据模型所属的状态机。
一个数据模型只能属于一个状态机,而一个状态机只能有一个数据模型。这种关系需要在状态机启动前设置。在数据模型上设置此属性将自动在stateMachine 上设置相应的dataModel
属性。
成员函数文档
[explicit]
QScxmlDataModel::QScxmlDataModel(QObject *parent = nullptr)
创建新的数据模型,父对象parent 。
[explicit protected]
QScxmlDataModel::QScxmlDataModel(QScxmlDataModelPrivate &dd, QObject *parent = nullptr)
从私有对象dd 创建一个新的数据模型,父对象parent 。
[static]
QScxmlDataModel *QScxmlDataModel::createScxmlDataModel(const QString &pluginKey)
通过pluginKey 指定的插件创建数据模型。
[pure virtual]
void QScxmlDataModel::evaluateAssignment(QScxmlExecutableContent::EvaluatorId id, bool *ok)
评估id 指向的赋值,如果有错误,则将ok 设为false
;如果没有错误,则将 设为true
。
[pure virtual]
void QScxmlDataModel::evaluateForeach(QScxmlExecutableContent::EvaluatorId id, bool *ok, QScxmlDataModel::ForeachLoopBody *body)
评估id 指向的foreach 循环,如果有错误,则将ok 设为false
;如果没有错误,则将 设为true
。每次迭代都会执行body 。
[pure virtual]
void QScxmlDataModel::evaluateInitialization(QScxmlExecutableContent::EvaluatorId id, bool *ok)
评估id 指向的初始化,如果有错误,则将ok 设为false
;如果没有错误,则将 设为true
。
[pure virtual]
bool QScxmlDataModel::evaluateToBool(QScxmlExecutableContent::EvaluatorId id, bool *ok)
评估id 指向的可执行内容,如果有错误,则将ok 设为false
;如果没有错误,则将 设为true
。评估结果以布尔值形式返回。
[pure virtual]
QString QScxmlDataModel::evaluateToString(QScxmlExecutableContent::EvaluatorId id, bool *ok)
评估id 指向的可执行内容,如果有错误,则将ok 设为false
;如果没有错误,则将 设为true
。评估结果以QString 的形式返回。
[pure virtual]
QVariant QScxmlDataModel::evaluateToVariant(QScxmlExecutableContent::EvaluatorId id, bool *ok)
评估id 指向的可执行内容,如果有错误,则将ok 设为false
;如果没有错误,则将 设为true
。评估结果以QVariant 的形式返回。
[pure virtual]
void QScxmlDataModel::evaluateToVoid(QScxmlExecutableContent::EvaluatorId id, bool *ok)
评估id 指向的可执行内容,如果有错误,则将ok 设为false
;如果没有错误,则将 设为true
。预计执行不会返回任何结果。
[pure virtual]
bool QScxmlDataModel::hasScxmlProperty(const QString &name) const
如果存在与给定name 对应的属性,则返回true
,否则返回false
。
[pure virtual]
QVariant QScxmlDataModel::scxmlProperty(const QString &name) const
返回属性name 的值。
另请参阅 setScxmlProperty() 。
[pure virtual]
void QScxmlDataModel::setScxmlEvent(const QScxmlEvent &event)
设置随后执行可执行内容时使用的event 。
[pure virtual]
bool QScxmlDataModel::setScxmlProperty(const QString &name, const QVariant &value, const QString &context)
为属性name 设置值value 。
context 是一个字符串,用于在错误信息中指示 SCXML 文件中发生错误的位置。
如果成功,则返回true
;如果出错,则返回false
。
另请参阅 scxmlProperty() 。
void QScxmlDataModel::setStateMachine(QScxmlStateMachine *stateMachine)
将此模型所属的状态机设置为stateMachine 。状态机和模型之间的关系是 1:1。设置一次状态机后,就不能再更改了。任何使用此方法设置状态机的尝试都将被忽略。
注: stateMachine 属性的设置函数。
另请参见 stateMachine().
[pure virtual invokable]
bool QScxmlDataModel::setup(const QVariantMap &initialDataValues)
使用initialDataValues 指定的初始值初始化数据模型。
如果出现解析错误或任何初始化步骤失败,则返回false
。否则返回true
。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
QScxmlStateMachine *QScxmlDataModel::stateMachine() const
返回与数据模型相关联的状态机。
注: 属性 stateMachine 的获取函数。
另请参阅 setStateMachine().
© 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.