# class KActionCollection

###

Module | kdeui
Namespace |
Class | KActionCollection
Inherits | QObject

A container for a set of QAction objects.

KActionCollection manages a set of QAction objects. It allows them to be grouped for organized presentation of configuration to the user, saving + loading of configuration, and optionally for automatic plugging into specified widget(s).

Additionally, KActionCollection provides several convenience functions for locating named actions, and actions grouped by QActionGroup.

If you create your own action collection and need to assign shortcuts to the actions within, you have to call associateWidget() or addAssociatedWidget() to have them working.

### methods

- KActionCollection (parent, cData)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  parent | QObject |
  cData | KComponentData | KComponentData()

  Constructor. Allows specification of a KComponentData other than the default global KComponentData, where needed.

- KActionCollection (parent)

  returns ctor
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  parent | KXMLGUIClient |

- KActionCollection (a0, a1)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QObject |
  a1 | KComponentData | KComponentData()

- action (index)

  returns QAction

  Argument | Type | Default
  --- | --- | ---
  index | int |

  Return the QAction* at position "index" in the action collection.

  This is equivalent to actions().value(index);

- action (name)

  returns QAction

  Argument | Type | Default
  --- | --- | ---
  name | QString |

  Get the action with the given name from the action collection.

  name - Name of the KAction Returns A pointer to the KAction in the collection which matches the parameters or null if nothing matches.

- actionGroups ( )

  returns QList<QActionGroup

  Returns the list of all QActionGroups associated with actions in this action collection.

- actionHighlighted (action)

  returns Nothing
  SIGNAL ("actionHighlighted (QAction*)")

  Argument | Type | Default
  --- | --- | ---
  action | QAction |

  Indicates that action was highlighted (hovered over). Deprecated Replaced by actionHovered(QAction* action);

- actionHovered (action)

  returns Nothing
  SIGNAL ("actionHovered (QAction*)")
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  action | QAction |

  Indicates that action was hovered.

- actionTriggered (action)

  returns Nothing
  SIGNAL ("actionTriggered (QAction*)")

  Argument | Type | Default
  --- | --- | ---
  action | QAction |

  Indicates that action was triggered

- actions ( )

  returns QList<QAction

  Returns the list of KActions which belong to this action collection.

- actionsWithoutGroup ( )

  returns QList<QAction

  Returns the list of KActions without an QAction.actionGroup() which belong to this action collection.

- addAction (name, action)

  returns QAction

  Argument | Type | Default
  --- | --- | ---
  name | QString |
  action | QAction |

  Add an action under the given name to the collection.

  Inserting an action that was previously inserted under a different name will replace the old entry, i.e. the action will not be available under the old name anymore but only under the new one.

  Inserting an action under a name that is already used for another action will replace the other action in the collection.

  name - The name by which the action be retrieved again from the collection.

  action - The action to add.

- addAction (name, action)

  returns KAction

  Argument | Type | Default
  --- | --- | ---
  name | QString |
  action | KAction |

- addAction (actionType, receiver, member)

  returns KAction

  Argument | Type | Default
  --- | --- | ---
  actionType | KStandardAction.StandardAction |
  receiver | QObject | 0
  member | char | 0

  Creates a new standard action, adds it to the collection and connects the action's triggered() signal to the specified receiver/member. The newly created action is also returned.

  The action can be retrieved later from the collection by its standard name as per KStandardAction.stdName.

- addAction (actionType, name, receiver, member)

  returns KAction

  Argument | Type | Default
  --- | --- | ---
  actionType | KStandardAction.StandardAction |
  name | QString |
  receiver | QObject | 0
  member | char | 0

  Creates a new standard action, adds to the collection under the given name and connects the action's triggered() signal to the specified receiver/member. The newly created action is also returned.

  The action can be retrieved later from the collection by the specified name.

- addAction (name, receiver, member)

  returns KAction

  Argument | Type | Default
  --- | --- | ---
  name | QString |
  receiver | QObject | 0
  member | char | 0

  Creates a new action under the given name to the collection and connects the action's triggered() signal to the specified receiver/member. The newly created action is returned.

  Inserting an action that was previously inserted under a different name will replace the old entry, i.e. the action will not be available under the old name anymore but only under the new one.

  Inserting an action under a name that is already used for another action will replace the other action in the collection.

  name - The name by which the action be retrieved again from the collection.

  action - The action to add.

- addAssociatedWidget (widget)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  widget | QWidget |

  Associate all actions in this collection to the given widget, including any actions added after this association is made.

  This does not change the action's shortcut context, so if you need to have the actions only trigger when the widget has focus, you'll need to set the shortcut context on each action to Qt.WidgetShortcut (or better still, Qt.WidgetWithChildrenShortcut with Qt 4.4+)

- allCollections ( )

  returns QList<KActionCollection
  static

  Access the list of all action collections in existence for this app

- associateWidget (widget)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  widget | QWidget |

  Associate all actions in this collection to the given widget. Unlike addAssociatedWidget, this method only adds all current actions in the collection to the given widget. Any action added after this call will not be added to the given widget automatically. So this is just a shortcut for a foreach loop and a widget->addAction call.

- associatedWidgets ( )

  returns QList<QWidget

  Return a list of all associated widgets.

- clear ( )

  returns Nothing

  Clears the entire action collection, deleting all actions.

- clearAssociatedWidgets ( )

  returns Nothing

  Clear all associated widgets and remove the actions from those widgets.

- componentData ( )

  returns KComponentData

  The KComponentData with which this class is associated.

- configGroup ( )

  returns QString

  Returns the KConfig group with which settings will be loaded and saved.

- configIsGlobal ( )

  returns bool

  Returns whether this action collection's configuration should be global to KDE ( true ), or specific to the application ( false ).

- connectNotify (signal)

  returns Nothing
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  signal | char |

  Overridden to perform connections when someone wants to know whether an action was highlighted or triggered

- count ( )

  returns int

  Returns the number of actions in the collection.

  This is equivalent to actions().count().

- exportGlobalShortcuts (config, writeDefaults)

  returns Nothing
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  config | KConfigGroup |
  writeDefaults | bool | 0

  Export the current configurable global key associations to config.

  \since 4.1

  config - Config object to save to

  writeDefaults - set to true to write settings which are already at defaults.

- importGlobalShortcuts (config)

  returns Nothing
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  config | KConfigGroup |

  Import from config all configurable global key associations.

  \since 4.1

  config - Config object to read from

- inserted (action)

  returns Nothing
  SIGNAL ("inserted (QAction*)")

  Argument | Type | Default
  --- | --- | ---
  action | QAction |

  Indicates that action was inserted into this action collection.

- isEmpty ( )

  returns bool

  Returns whether the action collection is empty or not.

- parentGUIClient ( )

  returns KXMLGUIClient

  The parent KXMLGUIClient, or null if not available.

- readSettings (config)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  config | KConfigGroup | 0

  Read all key associations from config.

  If config is zero, read all key associations from the application's configuration file KGlobal.config(), in the group set by setConfigGroup().

- removeAction (action)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  action | QAction |

  Removes an action from the collection and deletes it.

  action - The action to remove.

- removeAssociatedWidget (widget)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  widget | QWidget |

  Remove an association between all actions in this collection and the given widget, i.e. remove those actions from the widget, and stop associating newly added actions as well.

- removed (action)

  returns Nothing
  SIGNAL ("removed (QAction*)")

  Argument | Type | Default
  --- | --- | ---
  action | QAction |

  Indicates that action was removed from this action collection. Deprecated

- setComponentData (componentData)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  componentData | KComponentData |

  Set the componentData associated with this action collection.

  Don't call this method on a KActionCollection that contains actions. This is not supported.

  componentData - the KComponentData which is to be associated with this action collection, or an invalid KComponentData instance to indicate the default KComponentData.

- setConfigGlobal (global)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  global | bool |

  Set whether this action collection's configuration should be global to KDE ( true ), or specific to the application ( false ).

- setConfigGroup (group)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  group | QString |

  Sets group as the KConfig group with which settings will be loaded and saved.

- slotActionHighlighted ( )

  returns Nothing

  Internal Deprecated Replaced by slotActionHovered();

- slotActionTriggered ( )

  returns Nothing

- takeAction (action)

  returns QAction

  Argument | Type | Default
  --- | --- | ---
  action | QAction |

  Removes an action from the collection.

  action - the action to remove.

- writeSettings (config, writeDefaults, oneAction)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  config | KConfigGroup | 0
  writeDefaults | bool | 0
  oneAction | QAction | 0

  Write the current configurable key associations to config. What the function does if config is zero depends. If this action collection belongs to a KXMLGuiClient the setting are saved to the kxmlgui definition file. If not the settings are written to the applications config file.

  oneAction() and writeDefaults() have no meaning for the kxmlgui configuration file.

  config - Config object to save to, or null (see above)

  writeDefaults - set to true to write settings which are already at defaults.

  oneAction - pass an action here if you just want to save the values for one action, eg. if you know that action is the only one which has changed.