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 QTableWidgetItem

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

All Implemented Interfaces:
  QtJambiInterface

    public class QTableWidgetItem

extends QtJambiObject

The QTableWidgetItem class provides an item for use with the `QTableWidget` class. Table items are used to hold pieces of information for table widgets. Items usually contain text, icons, or checkboxes

The QTableWidgetItem class is a convenience class that replaces the `QTableItem` class in Qt 3. It provides an item for use with the `QTableWidget` class.

Top-level items are constructed without a parent then inserted at the position specified by a pair of row and column numbers:

            QTableWidgetItem newItem =
                new QTableWidgetItem(String.valueOf(Math.pow(row, column+1)));
            tableWidget.setItem(row, column, newItem);

Each item can have its own background brush which is set with the `setBackground()` function. The current background brush can be found with `background()`. The text label for each item can be rendered with its own font and brush. These are specified with the `setFont()` and `setForeground()` functions, and read with `font()` and `foreground()`.

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

## Subclassing

When subclassing QTableWidgetItem 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:
  `QTableWidget`, Model/View Programming, `QListWidgetItem`, and `QTreeWidgetItem`.

Nested Class Summary
`static class` | `QTableWidgetItem.ItemType` This enum describes the types that are used to describe table 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
`QTableWidgetItem()` Constructs a table item of the specified `type` that does not belong to any table.
`QTableWidgetItem(int type)` Constructs a table item of the specified `type` that does not belong to any table.
`QTableWidgetItem(QIcon icon, java.lang.String text)` Constructs a table item with the given `icon` and `text`.
`QTableWidgetItem(QIcon icon, java.lang.String text, int type)` Constructs a table item with the given `icon` and `text`.
`QTableWidgetItem(QTableWidgetItem other)` Constructs a copy of `other`.
`QTableWidgetItem(java.lang.String text)` Constructs a table item with the given `text`.
`QTableWidgetItem(java.lang.String text, int type)` Constructs a table item with the given `text`.

Method Summary
`QBrush` | `background()` Returns the brush used to render the item's background.
`Qt.CheckState` | `checkState()` Returns the checked state of the table item.
`QTableWidgetItem` | `clone()` This method is reimplemented for internal reasons
`int` | `column()` Returns the column of the item in the table.
`java.lang.Object` | `data(int role)` Returns the item's data for the given `role`.
`Qt.ItemFlags` | `flags()` Returns the flags used to describe the item.
`QFont` | `font()` Returns the font used to render the item's text.
`QBrush` | `foreground()` Returns the brush used to render the item's foreground (e.
`QIcon` | `icon()` Returns the item's icon.
`boolean` | `isSelected()` Returns true if the item is selected, otherwise returns false.
`boolean` | `operator_less(QTableWidgetItem other)` Returns true if the item is less than the `other` item; otherwise returns false.
`void` | `read(QDataStream in)` Reads the item from stream `in`.
`void` | `readFrom(QDataStream in)` Reads a QTableWidgetItem
`int` | `row()` Returns the row of the item in the table.
`void` | `setBackground(QBrush brush)` Sets the item's background brush to the specified `brush`.
`void` | `setCheckState(Qt.CheckState state)` Sets the check state of the table item to be `state`.
`void` | `setData(int role, java.lang.Object value)` Sets the item's data for the given `role` to the specified `value`.
`void` | `setFlags(Qt.ItemFlag[] flags)`
`void` | `setFlags(Qt.ItemFlags flags)` Sets the flags for the item to the given `flags`.
`void` | `setFont(QFont font)` Sets the font used to display the item's text to the given `font`.
`void` | `setForeground(QBrush brush)` Sets the item's foreground brush to the specified `brush`.
`void` | `setIcon(QIcon icon)` Sets the item's icon to the `icon` specified.
`void` | `setSelected(boolean select)` Sets the selected state of the item to `select`.
`void` | `setSizeHint(QSize size)` Sets the size hint for the table item to be `size`.
`void` | `setStatusTip(java.lang.String statusTip)` Sets the status tip for the table item to the text specified by `statusTip`.
`void` | `setText(java.lang.String text)` Sets the item's text to the `text` specified.
`void` | `setTextAlignment(int alignment)` Sets the text alignment for the item's text to the `alignment` specified.
`void` | `setToolTip(java.lang.String toolTip)` Sets the item's tooltip to the string specified by `toolTip`.
`void` | `setWhatsThis(java.lang.String whatsThis)` Sets the item's "What's This?" help to the string specified by `whatsThis`.
`QSize` | `sizeHint()` Returns the size hint set for the table item.
`java.lang.String` | `statusTip()` Returns the item's status tip.
`QTableWidget` | `tableWidget()` Returns the table widget that contains the item.
`java.lang.String` | `text()` Returns the item's text.
`int` | `textAlignment()` Returns the text alignment for the item's text.
`java.lang.String` | `toolTip()` Returns the item's tooltip.
`int` | `type()` Returns the type passed to the QTableWidgetItem constructor.
`java.lang.String` | `whatsThis()` Returns the item's "What's This?" help.
`void` | `write(QDataStream out)` Writes the item to stream `out`.
`void` | `writeTo(QDataStream out)` Writes thisQTableWidgetItem

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

### QTableWidgetItem

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

  Constructs a table item with the given `icon` and `text`.

See also:
  `type()`.

### QTableWidgetItem

    public QTableWidgetItem(QIcon icon,
                            java.lang.String text,
                            int type)

  Constructs a table item with the given `icon` and `text`.

See also:
  `type()`.

### QTableWidgetItem

    public QTableWidgetItem(java.lang.String text)

  Constructs a table item with the given `text`.

See also:
  `type()`.

### QTableWidgetItem

    public QTableWidgetItem(java.lang.String text,
                            int type)

  Constructs a table item with the given `text`.

See also:
  `type()`.

### QTableWidgetItem

    public QTableWidgetItem(QTableWidgetItem other)

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

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

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

### QTableWidgetItem

    public QTableWidgetItem()

  Constructs a table item of the specified `type` that does not belong to any table.

See also:
  `type()`.

### QTableWidgetItem

    public QTableWidgetItem(int type)

  Constructs a table item of the specified `type` that does not belong to any table.

See also:
  `type()`.

Method Detail

### background

    public final QBrush background()

  Returns the brush used to render the item's background.

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

### checkState

    public final Qt.CheckState checkState()

  Returns the checked state of the table item.

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

### column

    public final int column()

  Returns the column of the item in the table. If the item is not in a table, this function will return -1.

See also:
  `row()`.

### flags

    public final Qt.ItemFlags flags()

  Returns the flags used to describe the item. These determine whether the item can be checked, edited, and selected.

See also:
  `setFlags()`.

### font

    public final QFont font()

  Returns the font used to render the item's text.

See also:
  `setFont()`.

### foreground

    public final QBrush foreground()

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

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

### icon

    public final QIcon icon()

  Returns the item's icon.

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

### isSelected

    public final boolean isSelected()

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

See also:
  `setSelected()`.

### writeTo

    public final void writeTo(QDataStream out)

  Writes thisQTableWidgetItem

### readFrom

    public final void readFrom(QDataStream in)

  Reads a QTableWidgetItem

### row

    public final int row()

  Returns the row of the item in the table. If the item is not in a table, this function will return -1.

See also:
  `column()`.

### setBackground

    public final void setBackground(QBrush brush)

  Sets the item's background brush to the specified `brush`.

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

### setCheckState

    public final void setCheckState(Qt.CheckState state)

  Sets the check state of the table item to be `state`.

See also:
  `checkState()`.

### setFlags

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

### setFlags

    public final void setFlags(Qt.ItemFlags flags)

  Sets the flags for the item to the given `flags`. These determine whether the item can be selected or modified.

See also:
  `flags()`.

### setFont

    public final void setFont(QFont font)

  Sets the font used to display the item's text to the given `font`.

See also:
  `font()`, `setText()`, and `setForeground()`.

### setForeground

    public final void setForeground(QBrush brush)

  Sets the item's foreground brush to the specified `brush`.

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

### setIcon

    public final void setIcon(QIcon icon)

  Sets the item's icon to the `icon` specified.

See also:
  `icon()`, `setText()`, 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 table 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 table item to the text specified by `statusTip`. `QTableWidget` mouse tracking needs to be enabled for this feature to work.

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

### setText

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

  Sets the item's text to the `text` specified.

See also:
  `text()`, `setFont()`, and `setForeground()`.

### setTextAlignment

    public final void setTextAlignment(int alignment)

  Sets the text alignment for the item's text to the `alignment` specified.

See also:
  `textAlignment()`, and Qt::Alignment.

### setToolTip

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

  Sets the item's tooltip to the string specified by `toolTip`.

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

### setWhatsThis

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

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

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

### sizeHint

    public final QSize sizeHint()

  Returns the size hint set for the table item.

See also:
  `setSizeHint()`.

### statusTip

    public final java.lang.String statusTip()

  Returns the item's status tip.

See also:
  `setStatusTip()`.

### tableWidget

    public final QTableWidget tableWidget()

  Returns the table widget that contains the item.

### text

    public final java.lang.String text()

  Returns the item's text.

See also:
  `setText()`.

### textAlignment

    public final int textAlignment()

  Returns the text alignment for the item's text.

See also:
  `setTextAlignment()`, and Qt::Alignment.

### toolTip

    public final java.lang.String toolTip()

  Returns the item's tooltip.

See also:
  `setToolTip()`.

### type

    public final int type()

  Returns the type passed to the QTableWidgetItem constructor.

### whatsThis

    public final java.lang.String whatsThis()

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

See also:
  `setWhatsThis()`.

### clone

    public QTableWidgetItem clone()

  This method is reimplemented for internal reasons

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

### data

    public java.lang.Object data(int role)

  Returns the item's data for the given `role`.

See also:
  `setData()`.

### operator_less

    public boolean operator_less(QTableWidgetItem other)

  Returns true if the item is less than the `other` item; 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)

  Sets the item's data for the given `role` to the specified `value`.

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