# class KMenu

###

Module | kdeui
Namespace |
Class | KMenu
Inherits | QMenu

A menu with keyboard searching

KMenu is a class for menus with keyboard accessibility for popups with many options and/or varying options. It acts identically to QMenu, with the addition of setKeyboardShortcutsEnabled() and setKeyboardShortcutsExecute() methods.

The keyboard search algorithm is incremental with additional underlining for user feedback.

Author Daniel M. Duley <mosfet@kde.org> Author Hamish Rodda <rodda@kde.org>

### methods

- KMenu (parent)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  parent | QWidget | 0

  Constructs a KMenu.

- KMenu (title, parent)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  title | QString |
  parent | QWidget | 0

  Constructs a KMenu.

  title - The text displayed in a parent menu when it is inserted into another menu as a submenu.

  parent - the parent QWidget object

- KMenu (a0)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QWidget | 0

- KMenu (a0, a1)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QString |
  a1 | QWidget | 0

- aboutToShowContextMenu (menu, menuAction, ctxMenu)

  returns Nothing
  SIGNAL ("aboutToShowContextMenu (KMenu*, QAction*, QMenu*)")

  Argument | Type | Default
  --- | --- | ---
  menu | KMenu |
  menuAction | QAction |
  ctxMenu | QMenu |

  connect to this signal to be notified when a context menu is about to be shown

  menu - The menu that the context menu is about to be shown for

  menuAction - The action that the context menu is currently on

  ctxMenu - The context menu itself

- addTitle (text, before)

  returns QAction

  Argument | Type | Default
  --- | --- | ---
  text | QString |
  before | QAction | 0

  Inserts a title item with no icon.

- addTitle (icon, text, before)

  returns QAction

  Argument | Type | Default
  --- | --- | ---
  icon | QIcon |
  text | QString |
  before | QAction | 0

  Inserts a title item with the given icon and title.

- closeEvent (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QCloseEvent |

- contextMenu ( )

  returns QMenu

  Returns the context menu associated with this menu The data property of all actions inserted into the context menu is modified all the time to point to the action and menu it has been shown for

- contextMenu ( )

  returns QMenu
  Not implemented

  Returns the context menu associated with this menu

- contextMenuEvent (e)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  e | QContextMenuEvent |

- contextMenuFocus ( )

  returns KMenu
  static

  Returns the KMenu associated with the current context menu

- contextMenuFocusAction ( )

  returns QAction
  static

  returns the QAction associated with the current context menu

- focusNextPrevChild (next)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  next | bool |

- hideContextMenu ( )

  returns Nothing

  Hides the context menu if shown

- hideEvent (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QHideEvent |

- keyPressEvent (e)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  e | QKeyEvent |

- keyboardModifiers ( )

  returns Qt.KeyboardModifiers

  Return the state of the keyboard modifiers when the last menuitem was activated.

- mouseButtons ( )

  returns Qt.MouseButtons

  Return the state of the mouse buttons when the last menuitem was activated.

- mousePressEvent (e)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  e | QMouseEvent |

- mouseReleaseEvent (e)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  e | QMouseEvent |

- setKeyboardShortcutsEnabled (enable)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  enable | bool |

  Enables keyboard navigation by searching for the entered key sequence. Also underlines the currently selected item, providing feedback on the search.

  Defaults to off.

  calls to text() of currently keyboard-selected items will contain additional ampersand characters.

  though pre-existing keyboard shortcuts will not interfere with the operation of this feature, they may be confusing to the user as the existing shortcuts will not work. In addition, where text already contains ampersands, the underline produced is likely to confuse the user (as this feature uses underlining of text to indicate the current key selection sequence).

- setKeyboardShortcutsExecute (enable)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  enable | bool |

  Enables execution of the menu item once it is uniquely specified. Defaults to off.