Core::ActionBuilder Class
class Core::ActionBuilderActionBuilder 类是一个用于创建Core::Command的便捷类。更多内容...
| Header: | #include <coreplugin/actionmanager/actionmanager.h> |
公共函数
| ActionBuilder(QObject *contextActionParent, const Utils::Id actionId) | |
| ~ActionBuilder() | |
| Core::ActionBuilder & | adopt(Utils::Action *action) |
| Core::ActionBuilder & | setIconText(const QString &iconText) |
| Core::ActionBuilder & | setText(const QString &text) |
详细说明
操作构建器指定Core::Command 和上下文操作的属性,并在其析构函数中使用ActionManager::registerAction(),为该Command的Core::Context 集合实际注册操作。
成员函数文档
ActionBuilder::ActionBuilder(QObject *contextActionParent, const Utils::Id actionId)
为 ID 为actionId 的操作构建一个操作构建器。
contextActionParent 用于为内部构建的QAction 对象提供一个QObject 父类,以控制其生命周期。
这通常是使用ActionBuilder 的实体的this 指针。
[noexcept] ActionBuilder::~ActionBuilder()
将创建的操作及其设置的属性进行注册。
另请参阅 ActionManager::registerAction()。
Core::ActionBuilder &ActionBuilder::adopt(Utils::Action *action)
将给定的action 用作此构建器的contextAction。action 不能为nullptr,且在设置任何实际属性(如setText()或setIcon())之前,必须先调用adopt()。
通常,您应优先将contextActionParent 传递给ActionBuilder 的构造函数,并使用 bindContextAction() 将QAction 绑定到自动创建的上下文操作上。
当调用方自行管理操作的生命周期时,此方法有时会派上用场;例如,当没有QObject 可作为自动创建的上下文操作的父级时。
Core::ActionBuilder &ActionBuilder::setIconText(const QString &iconText)
将正在构建的操作的iconText 属性设置为iconText 。
另请参阅 QAction::setIconText()。
Core::ActionBuilder &ActionBuilder::setText(const QString &text)
将正在构建的操作的text 属性设置为text 。
另请参阅 QAction::setText()。
Copyright © The Qt Company Ltd. and other contributors. 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.