Core::IContext Class
class Core::IContextIContext 类将一个控件与上下文列表和上下文帮助相关联。更多内容...
| Header: | #include <coreplugin/icontext.h> |
| Inherits: | QObject |
| Inherited By: |
公共类型
公共函数
| IContext(QObject *parent = nullptr) | |
| Core::Context | context() const |
| void | contextHelp(const Core::IContext::HelpCallback &callback) const |
| void | setContext(const Core::Context &context) |
| void | setContextHelp(const Core::HelpItem &id) |
| void | setWidget(QWidget *widget) |
| QWidget * | widget() const |
详细说明
IContext 的实例必须通过Core::ICore::addContextObject() 进行注册才能生效。 对于 IContext 的许多子类(如Core::IEditor 和Core::IMode ),此操作会自动完成。但也可以手动创建 IContext 实例,为任意小部件关联上下文和上下文帮助。IContext 实例在被删除时会自动注销。如果需要手动注销 IContext 实例,请使用Core::ICore::removeContextObject()。
每当小部件属于应用程序级焦点小部件的父级链时,其关联的上下文列表就会被激活。这会激活为所包含的任何上下文 ID 注册的操作。如果用户请求上下文帮助,系统会请求焦点小部件父级层次结构中最顶层的 IContext 实例提供帮助。
有关如何利用上下文管理操作的概述,请参阅《操作管理器和命令》。
另请参阅 Core::ICore 、Core::Context 、Core::ActionManager 以及《操作管理器和命令》。
成员函数文档
IContext::IContext(QObject *parent = nullptr)
创建一个带有可选parent 的IContext。
Core::Context IContext::context() const
返回与该IContext 关联的上下文列表。
另请参阅 setContext()。
void IContext::contextHelp(const Core::IContext::HelpCallback &callback) const
当用户请求上下文帮助,且此IContext 在应用程序焦点控件的父级层次结构中处于最顶层时,将调用此方法。实现必须使用传入的callback 并传入生成的帮助项。默认实现将返回一个帮助项,其帮助ID由setContextHelp()设置。
另请参阅 setContextHelp()。
void IContext::setContext(const Core::Context &context)
将与该IContext 关联的上下文列表设置为context 。
另请参阅 context()。
void IContext::setContextHelp(const Core::HelpItem &id)
将与该IContext 关联的上下文帮助条目设置为id 。
另请参阅 contextHelp()。
void IContext::setWidget(QWidget *widget)
将与该IContext 关联的小部件设置为widget 。
另请参阅 widget()。
QWidget *IContext::widget() const
返回与该IContext 关联的小部件。
另请参阅 setWidget()。
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.