Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QTableWidgetItem Class Reference

The QTableWidgetItem class provides an item for use with the QTableWidget class. More...

    #include <QTableWidgetItem>

- List of all members, including inherited members

### Public Functions

- QTableWidgetItem ()
- QTableWidgetItem ( const QString & text )
- virtual ~QTableWidgetItem ()
- QColor backgroundColor () const
- int checked () const
- virtual void clear ()
- virtual QVariant data ( int role ) const
- QAbstractItemModel::ItemFlags flags () const
- QFont font () const
- QIcon icon () const
- void setBackgroundColor ( const QColor & color )
- void setChecked ( const bool checked )
- virtual void setData ( int role, const QVariant & value )
- void setFlags ( QAbstractItemModel::ItemFlags flags )
- void setFont ( const QFont & font )
- void setIcon ( const QIcon & icon )
- void setStatusTip ( const QString & statusTip )
- void setText ( const QString & text )
- void setTextAlignment ( int alignment )
- void setTextColor ( const QColor & color )
- void setToolTip ( const QString & toolTip )
- void setWhatsThis ( const QString & whatsThis )
- QString statusTip () const
- QTableWidget * tableWidget () const
- QString text () const
- int textAlignment () const
- QColor textColor () const
- QString toolTip () const
- QString whatsThis () const
- virtual bool operator< ( const QTableWidgetItem & other ) const

## Detailed Description

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.

Items are usually constructed with a table widget as their parent then inserted at a particular position specified by 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 color which is set with the setBackgroundColor() function. The current background color can be found with backgroundColor(). The text label for each item can be rendered with its own font and text color. These are specified with the setFont() and setTextColor() functions, and read with font() and textColor().

Items can be made checkable by setting the appropriate flag value with the setFlags() function. The current state of the item's flags can be read with flags().

See also QTableWidget.

## Member Function Documentation

### QTableWidgetItem::QTableWidgetItem ()

Constructs a table item that does not belong to any table.

### QTableWidgetItem::QTableWidgetItem ( const QString & text )

Constructs a table item with the given text.

### QTableWidgetItem::~QTableWidgetItem () `[virtual]`

Destroys the table item.

### QColor QTableWidgetItem::backgroundColor () const

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

See also textColor() and setBackgroundColor().

### int QTableWidgetItem::checked () const

Returns the checked state of the list item (see QCheckBox::ToggleState).

Only checkable items can be checked. By default, items are not checkable.

See also flags().

### void QTableWidgetItem::clear () `[virtual]`

Clears all the item's information.

### QVariant QTableWidgetItem::data ( int role ) const `[virtual]`

Returns the item's data for the given role.

### QAbstractItemModel::ItemFlags QTableWidgetItem::flags () const

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

See also setFlags().

### QFont QTableWidgetItem::font () const

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

See also setFont().

### QIcon QTableWidgetItem::icon () const

Returns the item's icon.

See also setIcon().

### void QTableWidgetItem::setBackgroundColor ( const QColor & color )

Sets the item's background color to the specified color.

See also backgroundColor() and setTextColor().

### void QTableWidgetItem::setChecked ( const bool checked )

Checks the item if checked is true; otherwise it will be shown as unchecked.

See also checked().

### void QTableWidgetItem::setData ( int role, const QVariant & value ) `[virtual]`

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

### void QTableWidgetItem::setFlags ( QAbstractItemModel::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().

### void QTableWidgetItem::setFont ( const QFont & font )

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

See also font(), setText(), and setTextColor().

### void QTableWidgetItem::setIcon ( const QIcon & icon )

Sets the item's icon to the icon specified.

See also icon() and setText().

### void QTableWidgetItem::setStatusTip ( const QString & statusTip )

Sets the item's status tip to the string specified by statusTip.

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

### void QTableWidgetItem::setText ( const QString & text )

Sets the item's text to the text specified.

See also text(), setFont(), and setTextColor().

### void QTableWidgetItem::setTextAlignment ( int alignment )

Sets the text alignment for the item's text to the alignment specified (see Qt::AlignmentFlag).

### void QTableWidgetItem::setTextColor ( const QColor & color )

Sets the color used to display the item's text to the given color.

See also textColor(), setFont(), and setText().

### void QTableWidgetItem::setToolTip ( const QString & toolTip )

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

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

### void QTableWidgetItem::setWhatsThis ( const QString & whatsThis )

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

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

### QString QTableWidgetItem::statusTip () const

Returns the item's status tip.

See also setStatusTip().

### QTableWidget * QTableWidgetItem::tableWidget () const

Returns the table widget that contains the item.

### QString QTableWidgetItem::text () const

Returns the item's text.

See also setText().

### int QTableWidgetItem::textAlignment () const

Returns the text alignment for the item's text (see Qt::AlignmentFlag).

### QColor QTableWidgetItem::textColor () const

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

See also backgroundColor() and setTextColor().

### QString QTableWidgetItem::toolTip () const

Returns the item's tooltip.

See also setToolTip().

### QString QTableWidgetItem::whatsThis () const

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

See also setWhatsThis().

### bool QTableWidgetItem::operator< ( const QTableWidgetItem & other ) const `[virtual]`

Returns true if the item is less than the other item; otherwise returns false.