KShortcutWidget Class

Header: #include <KShortcutWidget>
CMake: find_package(KF6 REQUIRED COMPONENTS XmlGui)
target_link_libraries(mytarget PRIVATE KF6::XmlGui)
Inherits: QWidget

Properties

Public Functions

KShortcutWidget(QWidget *parent = nullptr)
virtual ~KShortcutWidget() override
bool isModifierlessAllowed()
(since 4.1) void setCheckActionCollections(const QList<KActionCollection *> &actionCollections)
void setClearButtonsShown(bool show)
void setModifierlessAllowed(bool allow)
QList<QKeySequence> shortcut() const

Public Slots

void applyStealShortcut()
void clearShortcut()
void setShortcut(const QList<QKeySequence> &cut)

Signals

void shortcutChanged(const QList<QKeySequence> &cut)

Detailed Description

Provides a widget that lets the user assign a main shortcut and an alternate shortcut for a certain action.

"KShortcutWidget"

Property Documentation

modifierlessAllowed : bool

Access functions:

Member Function Documentation

[explicit] KShortcutWidget::KShortcutWidget(QWidget *parent = nullptr)

Creates a new shortcut widget as a child of parent.

[override virtual noexcept] KShortcutWidget::~KShortcutWidget()

Destructs the shortcut widget.

[slot] void KShortcutWidget::applyStealShortcut()

Actually remove the shortcut that the user wanted to steal, from the action that was using it.

To be called before you apply your changes. No shortcuts are stolen until this function is called.

[slot] void KShortcutWidget::clearShortcut()

Unassigns the widget's shortcut.

bool KShortcutWidget::isModifierlessAllowed()

Returns whether the set widget shortcut can be set without including a modifier key.

Note: Getter function for property modifierlessAllowed.

[since 4.1] void KShortcutWidget::setCheckActionCollections(const QList<KActionCollection *> &actionCollections)

Sets a list of actionCollections to check against for a conflictuous shortcut.

If there is a conflictuous shortcut with a QAction, and that this shortcut can be configured (that is, KActionCollection::isShortcutConfigurable() returns true) the user will be prompted to eventually steal the shortcut from this action.

Global shortcuts are automatically checked for conflicts.

Don't forget to call applyStealShortcut() to actually steal the shortcut.

This function was introduced in 4.1.

void KShortcutWidget::setClearButtonsShown(bool show)

Sets whether to show the clear buttons next to the main and alternate shortcuts of the widget.

void KShortcutWidget::setModifierlessAllowed(bool allow)

Sets whether to allow a shortcut that doesn't include a modifier key.

Note: Setter function for property modifierlessAllowed.

See also isModifierlessAllowed().

[slot] void KShortcutWidget::setShortcut(const QList<QKeySequence> &cut)

Sets the given shortcut cut to the widget.

See also shortcut().

QList<QKeySequence> KShortcutWidget::shortcut() const

Returns the set shortcut.

See also setShortcut().

[signal] void KShortcutWidget::shortcutChanged(const QList<QKeySequence> &cut)

Emitted when the given shortcut cut has changed.