Qt Jambi Home

com.trolltech.qt.gui
Class QTableWidgetItem

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by 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(tr("%1").arg(
            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 setChecked() function. The corresponding checked() 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, 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<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Constructor Summary
QTableWidgetItem()
          Equivalent to QTableWidgetItem(Type).
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)
          Equivalent to QTableWidgetItem(icon, text, Type).
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)
          Equivalent to QTableWidgetItem(text, Type).
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()
          Creates a copy of the item.
 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.g. text).
static QTableWidgetItem fromNativePointer(QNativePointer nativePointer)
          This function returns the QTableWidgetItem instance pointed to by nativePointer
 QIcon icon()
          Returns the item's icon.
 boolean isSelected()
          Returns true if the item is selected, otherwise returns false.
 void read(QDataStream in)
          Reads the item from stream in.
 void readFrom(QDataStream in)
          Reads a QTableWidgetItem from in.
 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)
          Sets the flags for the item to the given 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 item's status tip to the string 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?
 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?
 void write(QDataStream out)
          Writes the item to stream out.
 void writeTo(QDataStream out)
          Writes thisQTableWidgetItem to out.
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class java.lang.Object
equals, 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)

Equivalent to QTableWidgetItem(icon, text, 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)

Equivalent to QTableWidgetItem(text, Type).


QTableWidgetItem

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

Constructs a table item with the given text.

See Also:
type

QTableWidgetItem

public QTableWidgetItem()

Equivalent to QTableWidgetItem(Type).


QTableWidgetItem

public QTableWidgetItem(int type)

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

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, flags
Method Detail

background

public final QBrush background()

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

See Also:
setBackground, foreground

checkState

public final Qt.CheckState checkState()

Returns the checked state of the table item.

See Also:
setCheckState, 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.g. text).

See Also:
setForeground, background

icon

public final QIcon icon()

Returns the item's icon.

See Also:
setIcon, 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 to out.


readFrom

public final void readFrom(QDataStream in)
Reads a QTableWidgetItem from in.


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, 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)

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

See Also:
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, setForeground

setForeground

public final void setForeground(QBrush brush)

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

See Also:
foreground, setBackground

setIcon

public final void setIcon(QIcon icon)

Sets the item's icon to the icon specified.

See Also:
icon, setText, 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 item's status tip to the string specified by statusTip.

See Also:
statusTip, setToolTip, setWhatsThis

setText

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

Sets the item's text to the text specified.

See Also:
text, setFont, setForeground

setTextAlignment

public final void setTextAlignment(int alignment)

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

See Also:
textAlignment, 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, 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, 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, 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()

Creates a copy of the item.

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

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, data

write

public void write(QDataStream out)

Writes the item to stream out.

See Also:
read

fromNativePointer

public static QTableWidgetItem fromNativePointer(QNativePointer nativePointer)
This function returns the QTableWidgetItem instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

Qt Jambi Home