IContext Class
class Core::IContextThe IContext class associates a widget with a context list and context help. More...
Header: | #include <coreplugin/icontext.h> |
Inherits: | QObject |
Inherited By: |
Public Types
Public Functions
IContext(QObject *parent = nullptr) | |
virtual Core::Context | context() const |
virtual void | contextHelp(const Core::IContext::HelpCallback &callback) const |
virtual void | setContext(const Core::Context &context) |
virtual void | setContextHelp(const Core::HelpItem &id) |
virtual void | setWidget(QWidget *widget) |
virtual QWidget * | widget() const |
Detailed Description
An instance of IContext must be registered with Core::ICore::addContextObject() to have an effect. For many subclasses of IContext, like Core::IEditor and Core::IMode, this is done automatically. But instances of IContext can be created manually to associate a context and context help for an arbitrary widget, too. IContext instances are automatically unregistered when they are deleted. Use Core::ICore::removeContextObject() if you need to unregister an IContext instance manually.
Whenever the widget is part of the application wide focus widget's parent chain, the associated context list is made active. This makes actions active that were registered for any of the included context IDs. If the user requests context help, the top-most IContext instance in the focus widget's parent hierarchy is asked to provide it.
See The Action Manager and Commands for an overview of how contexts are used for managing actions.
See also Core::ICore, Core::Context, Core::ActionManager, and The Action Manager and Commands.
Member Type Documentation
[alias]
IContext::HelpCallback
The HelpCallback class defines the callback function that is used to report the help item to show when the user requests context help.
Member Function Documentation
IContext::IContext(QObject *parent = nullptr)
Creates an IContext with an optional parent.
[virtual]
Core::Context IContext::context() const
Returns the context list associated with this IContext.
See also setContext().
[virtual]
void IContext::contextHelp(const Core::IContext::HelpCallback &callback) const
Called when the user requests context help and this IContext is the top-most in the application focus widget's parent hierarchy. Implementations must call the passed callback with the resulting help item. The default implementation returns an help item with the help ID that was set with setContextHelp().
See also setContextHelp().
[virtual]
void IContext::setContext(const Core::Context &context)
Sets the context list associated with this IContext to context.
See also context().
[virtual]
void IContext::setContextHelp(const Core::HelpItem &id)
Sets the context help item associated with this IContext to id.
See also contextHelp().
[virtual]
void IContext::setWidget(QWidget *widget)
Sets the widget associated with this IContext to widget.
See also widget().
[virtual]
QWidget *IContext::widget() const
Returns the widget associated with this IContext.
See also setWidget().
© 2024 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.