Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QListWidgetItem

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.gui.QListWidgetItem

All Implemented Interfaces:
  QtJambiInterface

    public class QListWidgetItem

extends QtJambiObject

The `QListWidgetItem` class provides an item for use with the `QListWidget` item view class. `QListWidgetItem` is used to represent items in a list provided by the `QListWidget` class. Each item can hold several pieces of information, and will display these appropriately.

The item view convenience classes use a classic item-based interface rather than a pure model/view approach. For a more flexible list view widget, consider using the `QListView` class with a standard model.

List items can be automatically inserted into a list when they are constructed by specifying the list widget:

            new QListWidgetItem(tr("Hazel"), listWidget);

They can also be created without a parent widget, and later inserted into a list (see `QListWidget::insertItem()`).

List items are typically used to display `text()` and an `icon()`. These are set with the `setText()` and `setIcon()` functions. The appearance of the text can be customized with `setFont()`, `setForeground()`, and `setBackground()`. Text in list items can be aligned using the `setTextAlignment()` function. Tooltips, status tips and "What's This?" help can be added to list items with `setToolTip()`, `setStatusTip()`, and `setWhatsThis()`.

By default, items are enabled, selectable, checkable, and can be the source of a drag and drop operation. Each item's flags can be changed by calling `setFlags()` with the appropriate value (see Qt::ItemFlags). Checkable items can be checked, unchecked and partially checked with the `setCheckState()` function. The corresponding `checkState()` function indicates what check state the item currently has.

The `isHidden()` function can be used to determine whether the item is hidden. Items can be hidden with `setHidden()`.

## Subclassing

When subclassing `QListWidgetItem` to provide custom items, it is possible to define new types for them so that they can be distinguished from standard items. The constructors for subclasses that require this feature need to call the base class constructor with a new type value equal to or greater than `UserType` .

See also:
  `QListWidget`, Model/View Programming, `QTreeWidgetItem`, and `QTableWidgetItem`.

Nested Class Summary
`static class` | `QListWidgetItem.ItemType` This enum describes the types that are used to describe tree widget items.

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QListWidgetItem()` Constructs an empty list widget item of the specified `type` with the given `parent`.
`QListWidgetItem(QIcon icon, java.lang.String text)` Constructs an empty list widget item of the specified `type` with the given `icon`, `text` and `parent`.
`QListWidgetItem(QIcon icon, java.lang.String text, QListWidget view)` Constructs an empty list widget item of the specified `type` with the given `icon`, `text` and `parent`.
`QListWidgetItem(QIcon icon, java.lang.String text, QListWidget view, int type)` Constructs an empty list widget item of the specified `type` with the given `icon`, `text` and `parent`.
`QListWidgetItem(QListWidget view)` Constructs an empty list widget item of the specified `type` with the given `parent`.
`QListWidgetItem(QListWidget view, int type)` Constructs an empty list widget item of the specified `type` with the given `parent`.
`QListWidgetItem(QListWidgetItem other)` Constructs a copy of `other`.
`QListWidgetItem(java.lang.String text)` Constructs an empty list widget item of the specified `type` with the given `text` and `parent`.
`QListWidgetItem(java.lang.String text, QListWidget view)` Constructs an empty list widget item of the specified `type` with the given `text` and `parent`.
`QListWidgetItem(java.lang.String text, QListWidget view, int type)` Constructs an empty list widget item of the specified `type` with the given `text` and `parent`.

Method Summary
`QBrush` | `background()` Returns the brush used to display the list item's background.
`Qt.CheckState` | `checkState()` Returns the checked state of the list item (see `Qt::CheckState` ).
`QListWidgetItem` | `clone()` This method is reimplemented for internal reasons
`java.lang.Object` | `data(int role)` This function returns the item's data for a given `role` (see `Qt::ItemDataRole` ).
`Qt.ItemFlags` | `flags()` Returns the item flags for this item (see Qt.:ItemFlags).
`QFont` | `font()` Returns the font used to display this list item's text.
`QBrush` | `foreground()` Returns the brush used to display the list item's foreground (e.
`QIcon` | `icon()` Returns the list item's icon.
`boolean` | `isHidden()` Returns true if the item is hidden, otherwise returns false.
`boolean` | `isSelected()` Returns true if the item is selected, otherwise returns false.
`QListWidget` | `listWidget()` Returns the list widget that contains the item.
`boolean` | `operator_less(QListWidgetItem other)` Returns true if this item's text is less then `other` item's text; otherwise returns false.
`void` | `read(QDataStream in)` Reads the item from stream `in`.
`void` | `readFrom(QDataStream in)` Reads a QListWidgetItem
`void` | `setBackground(QBrush brush)` Sets the background brush of the list item to the given `brush`.
`void` | `setCheckState(Qt.CheckState state)` Sets the check state of the list item to `state`.
`void` | `setData(int role, java.lang.Object value)` This function sets the data for a given `role` to the given `value` (see `Qt::ItemDataRole` ).
`void` | `setFlags(Qt.ItemFlag[] flags)` Sets the item flags for the list item to `flags` (see Qt.:ItemFlags).
`void` | `setFlags(Qt.ItemFlags flags)` Sets the item flags for the list item to `flags` (see Qt.:ItemFlags).
`void` | `setFont(QFont font)` Sets the font used when painting the item to the given `font`.
`void` | `setForeground(QBrush brush)` Sets the foreground brush of the list item to the given `brush`.
`void` | `setHidden(boolean hide)` Hides the item if `hide` is true, otherwise shows the item.
`void` | `setIcon(QIcon icon)` Sets the icon for the list item to the given `icon`.
`void` | `setSelected(boolean select)` Sets the selected state of the item to `select`.
`void` | `setSizeHint(QSize size)` Sets the size hint for the list item to be `size`.
`void` | `setStatusTip(java.lang.String statusTip)` Sets the status tip for the list item to the text specified by `statusTip`.
`void` | `setText(java.lang.String text)` Sets the text for the list widget item's to the given `text`.
`void` | `setTextAlignment(int alignment)` Sets the list item's text alignment to `alignment` (see `Qt::AlignmentFlag` ).
`void` | `setToolTip(java.lang.String toolTip)` Sets the tooltip for the list item to the text specified by `toolTip`.
`void` | `setWhatsThis(java.lang.String whatsThis)` Sets the "What's This?" help for the list item to the text specified by `whatsThis`.
`QSize` | `sizeHint()` Returns the size hint set for the list item.
`java.lang.String` | `statusTip()` Returns the list item's status tip.
`java.lang.String` | `text()` Returns the list item's text.
`int` | `textAlignment()` Returns the text alignment for the list item (see `Qt::AlignmentFlag` ).
`java.lang.String` | `toolTip()` Returns the list item's tooltip.
`int` | `type()` Returns the type passed to the `QListWidgetItem` constructor.
`java.lang.String` | `whatsThis()` Returns the list item's "What's This?" help text.
`void` | `write(QDataStream out)` Writes the item to stream `out`.
`void` | `writeTo(QDataStream out)` Writes thisQListWidgetItem

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QListWidgetItem

    public QListWidgetItem(QListWidget view)

  Constructs an empty list widget item of the specified `type` with the given `parent`. If the parent is not specified, the item will need to be inserted into a list widget with `QListWidget::insertItem()`.

See also:
  `type()`.

### QListWidgetItem

    public QListWidgetItem()

  Constructs an empty list widget item of the specified `type` with the given `parent`. If the parent is not specified, the item will need to be inserted into a list widget with `QListWidget::insertItem()`.

See also:
  `type()`.

### QListWidgetItem

    public QListWidgetItem(QListWidget view,
                           int type)

  Constructs an empty list widget item of the specified `type` with the given `parent`. If the parent is not specified, the item will need to be inserted into a list widget with `QListWidget::insertItem()`.

See also:
  `type()`.

### QListWidgetItem

    public QListWidgetItem(QIcon icon,
                           java.lang.String text,
                           QListWidget view)

  Constructs an empty list widget item of the specified `type` with the given `icon`, `text` and `parent`. If the parent is not specified, the item will need to be inserted into a list widget with `QListWidget::insertItem()`.

See also:
  `type()`.

### QListWidgetItem

    public QListWidgetItem(QIcon icon,
                           java.lang.String text)

  Constructs an empty list widget item of the specified `type` with the given `icon`, `text` and `parent`. If the parent is not specified, the item will need to be inserted into a list widget with `QListWidget::insertItem()`.

See also:
  `type()`.

### QListWidgetItem

    public QListWidgetItem(QIcon icon,
                           java.lang.String text,
                           QListWidget view,
                           int type)

  Constructs an empty list widget item of the specified `type` with the given `icon`, `text` and `parent`. If the parent is not specified, the item will need to be inserted into a list widget with `QListWidget::insertItem()`.

See also:
  `type()`.

### QListWidgetItem

    public QListWidgetItem(QListWidgetItem other)

  Constructs a copy of `other`. Note that `type()` and `listWidget()` are not copied.

  This function is useful when reimplementing `clone()`.

See also:
  `data()`, and `flags()`.

### QListWidgetItem

    public QListWidgetItem(java.lang.String text,
                           QListWidget view)

  Constructs an empty list widget item of the specified `type` with the given `text` and `parent`. If the parent is not specified, the item will need to be inserted into a list widget with `QListWidget::insertItem()`.

See also:
  `type()`.

### QListWidgetItem

    public QListWidgetItem(java.lang.String text)

  Constructs an empty list widget item of the specified `type` with the given `text` and `parent`. If the parent is not specified, the item will need to be inserted into a list widget with `QListWidget::insertItem()`.

See also:
  `type()`.

### QListWidgetItem

    public QListWidgetItem(java.lang.String text,
                           QListWidget view,
                           int type)

  Constructs an empty list widget item of the specified `type` with the given `text` and `parent`. If the parent is not specified, the item will need to be inserted into a list widget with `QListWidget::insertItem()`.

See also:
  `type()`.

Method Detail

### background

    public final QBrush background()

  Returns the brush used to display the list item's background.

See also:
  `setBackground()`, and `foreground()`.

### checkState

    public final Qt.CheckState checkState()

  Returns the checked state of the list item (see `Qt::CheckState` ).

See also:
  `setCheckState()`, and `flags()`.

### flags

    public final Qt.ItemFlags flags()

  Returns the item flags for this item (see Qt.:ItemFlags).

See also:
  `setFlags()`.

### font

    public final QFont font()

  Returns the font used to display this list item's text.

See also:
  `setFont()`.

### foreground

    public final QBrush foreground()

  Returns the brush used to display the list item's foreground (e. . text).

See also:
  `setForeground()`, and `background()`.

### icon

    public final QIcon icon()

  Returns the list item's icon.

See also:
  `setIcon()`, and `iconSize`.

### isHidden

    public final boolean isHidden()

  Returns true if the item is hidden, otherwise returns false.

See also:
  `setHidden()`.

### isSelected

    public final boolean isSelected()

  Returns true if the item is selected, otherwise returns false.

See also:
  `setSelected()`.

### listWidget

    public final QListWidget listWidget()

  Returns the list widget that contains the item.

### writeTo

    public final void writeTo(QDataStream out)

  Writes thisQListWidgetItem

### readFrom

    public final void readFrom(QDataStream in)

  Reads a QListWidgetItem

### setBackground

    public final void setBackground(QBrush brush)

  Sets the background brush of the list item to the given `brush`.

See also:
  `background()`, and `setForeground()`.

### setCheckState

    public final void setCheckState(Qt.CheckState state)

  Sets the check state of the list item to `state`.

See also:
  `checkState()`.

### setFlags

    public final void setFlags(Qt.ItemFlag[] flags)

  Sets the item flags for the list item to `flags` (see Qt.:ItemFlags).

See also:
  `flags()`.

### setFlags

    public final void setFlags(Qt.ItemFlags flags)

  Sets the item flags for the list item to `flags` (see Qt.:ItemFlags).

See also:
  `flags()`.

### setFont

    public final void setFont(QFont font)

  Sets the font used when painting the item to the given `font`.

See also:
  `font()`.

### setForeground

    public final void setForeground(QBrush brush)

  Sets the foreground brush of the list item to the given `brush`.

See also:
  `foreground()`, and `setBackground()`.

### setHidden

    public final void setHidden(boolean hide)

  Hides the item if `hide` is true, otherwise shows the item.

See also:
  `isHidden()`.

### setIcon

    public final void setIcon(QIcon icon)

  Sets the icon for the list item to the given `icon`.

See also:
  `icon()`, `text()`, and `iconSize`.

### setSelected

    public final void setSelected(boolean select)

  Sets the selected state of the item to `select`.

See also:
  `isSelected()`.

### setSizeHint

    public final void setSizeHint(QSize size)

  Sets the size hint for the list item to be `size`. If no size hint is set, the item delegate will compute the size hint based on the item data.

See also:
  `sizeHint()`.

### setStatusTip

    public final void setStatusTip(java.lang.String statusTip)

  Sets the status tip for the list item to the text specified by `statusTip`.

See also:
  `statusTip()`, `setToolTip()`, and `setWhatsThis()`.

### setText

    public final void setText(java.lang.String text)

  Sets the text for the list widget item's to the given `text`.

See also:
  `text()`.

### setTextAlignment

    public final void setTextAlignment(int alignment)

  Sets the list item's text alignment to `alignment` (see `Qt::AlignmentFlag` ).

See also:
  `textAlignment()`.

### setToolTip

    public final void setToolTip(java.lang.String toolTip)

  Sets the tooltip for the list item to the text specified by `toolTip`.

See also:
  `toolTip()`, `setStatusTip()`, and `setWhatsThis()`.

### setWhatsThis

    public final void setWhatsThis(java.lang.String whatsThis)

  Sets the "What's This?" help for the list item to the text specified by `whatsThis`.

See also:
  `whatsThis()`, `setStatusTip()`, and `setToolTip()`.

### sizeHint

    public final QSize sizeHint()

  Returns the size hint set for the list item.

See also:
  `setSizeHint()`.

### statusTip

    public final java.lang.String statusTip()

  Returns the list item's status tip.

See also:
  `setStatusTip()`.

### text

    public final java.lang.String text()

  Returns the list item's text.

See also:
  `setText()`.

### textAlignment

    public final int textAlignment()

  Returns the text alignment for the list item (see `Qt::AlignmentFlag` ).

See also:
  `setTextAlignment()`.

### toolTip

    public final java.lang.String toolTip()

  Returns the list item's tooltip.

See also:
  `setToolTip()`, `statusTip()`, and `whatsThis()`.

### type

    public final int type()

  Returns the type passed to the `QListWidgetItem` constructor.

### whatsThis

    public final java.lang.String whatsThis()

  Returns the list item's "What's This?" help text.

See also:
  `setWhatsThis()`, `statusTip()`, and `toolTip()`.

### clone

    public QListWidgetItem clone()

  This method is reimplemented for internal reasons

  Overrides:
    `clone` in class `java.lang.Object`

### data

    public java.lang.Object data(int role)

  This function returns the item's data for a given `role` (see `Qt::ItemDataRole` ). Reimplement this function if you need extra roles or special behavior for certain roles.

See also:
  `setData()`.

### operator_less

    public boolean operator_less(QListWidgetItem other)

  Returns true if this item's text is less then `other` item's text; otherwise returns false.

### read

    public void read(QDataStream in)

  Reads the item from stream `in`.

See also:
  `write()`.

### setData

    public void setData(int role,
                        java.lang.Object value)

  This function sets the data for a given `role` to the given `value` (see `Qt::ItemDataRole` ). Reimplement this function if you need extra roles or special behavior for certain roles.

See also:
  `Qt::ItemDataRole` , and `data()`.

### write

    public void write(QDataStream out)

  Writes the item to stream `out`.

See also:
  `read()`.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD