KCommandBar Class
A hud style menu which allows listing and executing actions. More...
| Header: | #include <KCommandBar> | 
| CMake: | find_package(KF6 REQUIRED COMPONENTS ConfigWidgets)target_link_libraries(mytarget PRIVATE KF6::ConfigWidgets) | 
| Inherits: | QFrame | 
Public Types
| struct | ActionGroup | 
Public Functions
| KCommandBar(QWidget *parent) | |
| void | setActions(const QList<KCommandBar::ActionGroup> &actions) | 
Public Slots
| void | show() | 
Detailed Description
KCommandBar takes as input a list of QActions and then shows them in a "list-like-view" with a filter line edit. This allows quickly executing an action.
Usage is simple. Just create a KCommandBar instance when you need it and throw it away once the user is done with it. You can store it as a class member as well but there is little benefit in that. Example:
void slotOpenCommandBar() { // `this` is important, you must pass a parent widget // here. Ideally it will be your mainWindow KCommandBar *bar = new KCommandBar(this); // Load actions into the command bar // These actions can be from your menus / toolbars etc QList<ActionGroup> actionGroups = ...; bar->setActions(actionGroups); // Show bar->show(); }
Member Function Documentation
[explicit] KCommandBar::KCommandBar(QWidget *parent)
Constructor
parent is used to determine position and size of the command bar. It *must* not be nullptr.
void KCommandBar::setActions(const QList<KCommandBar::ActionGroup> &actions)
actions is a list of {GroupName, QAction}. Group name can be the name of the component/menu where a QAction lives, for example in a menu "File -> Open File", "File" should be the GroupName.