# class KWidgetItemDelegate

### abstract

Module | kdeui
Namespace |
Class | KWidgetItemDelegate
Inherits | QAbstractItemDelegate

This class allows to create item delegates embedding simple widgets to interact with items. For instance you can add push buttons, line edits, etc. to your delegate and use them to modify the state of your model.

@since 4.1

### methods

- KWidgetItemDelegate (itemView, parent)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  itemView | QAbstractItemView |
  parent | QObject | 0

  Creates a new ItemDelegate to be used with a given itemview.

  itemView - the item view the new delegate will monitor

  parent - the parent of this delegate

- blockedEventTypes (widget)

  returns QList<QEvent::Type>

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

  Retrieves the list of blocked event types for the given widget.

  widget - the specified widget.

  Returns the list of blocked event types, can be empty if no events are blocked.

- createItemWidgets ( )

  returns QList<QWidget
  pure virtual

  Creates the list of widgets needed for an item.

  No initialization of the widgets is supposed to happen here. The widgets will be initialized based on needs for a given item.

  If you want to connect some widget signals to any slot, you should do it here.

  Returns the list of newly created widgets which will be used to interact with an item.

  See also updateItemWidgets()

- focusedIndex ( )

  returns QPersistentModelIndex

  Retrieves the currently focused index. An invalid index if none is focused.

  Returns the current focused index, or QPersistentModelIndex() if none is focused.

- itemView ( )

  returns QAbstractItemView

  Retrieves the item view this delegate is monitoring.

  Returns the item view this delegate is monitoring

- paintWidgets (painter, option, index)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  painter | QPainter |
  option | QStyleOptionViewItem |
  index | QPersistentModelIndex |

  Paint the widgets of the item. This method is meant to be used in the paint() method of your item delegate implementation.

  painter - the painter the widgets will be painted on.

  option - the current set of style options for the view.

  index - the model index of the item currently painted.

- setBlockedEventTypes (widget, types)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  widget | QWidget |
  types | QList<QEvent::Type> |

  Sets the list of event types that a widget will block.

  Blocked events are not passed to the view. This way you can prevent an item from being selected when a button is clicked for instance.

  widget - the widget which must block events

  types - the list of event types the widget must block

- updateItemWidgets (widgets, option, index)

  returns Nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  widgets | QList<QWidget |
  option | QStyleOptionViewItem |
  index | QPersistentModelIndex |

  Updates a list of widgets for its use inside of the delegate (painting or event handling).

  All the positioning and sizing should be done in item coordinates.

  Do not make widget connections in here, since this method will be called very regularly.

  widgets - the widgets to update

  option - the current set of style options for the view.

  index - the model index of the item currently manipulated.