Classes - Annotated - Tree - Functions - Home - Structure Qte

QTableItem Class Reference
[ table module ]

The QTableItem class provides content for one cell in a QTable. More...

#include <qtable.h>

Inherits Qt.

List of all member functions.

Public Members

Detailed Description

The QTableItem class provides content for one cell in a QTable.

A QTableItem contains the data of a table cell, specifies its edit type and the editor used to change its content. Furthermore, it defines its size, the alignment of the data to display, whether the data can be replaced, and provides the API needed for sorting table items.

Items may contain text and pixmaps and offer a QLineEdit for editing. By reimplementing paint(), key(), createEditor() and setContentFromEditor() you can change these default settings.

To get rid of an item, simply delete it. By doing so, all required actions for removing it from the table will be taken.

Member Type Documentation


This enum type defines whether and when the user may edit a table cell. The currently defined states are:

Member Function Documentation

QTableItem::QTableItem ( QTable * table, EditType et, const QString & text )

Creates a table item for the table table that contains the text text.

QTableItem::QTableItem ( QTable * table, EditType et, const QString & text, const QPixmap & p )

Creates an item for the table table with the text text and the pixmap p.

QTableItem::~QTableItem () [virtual]


int QTableItem::alignment () const [virtual]

The alignment function returns how the contents of the cell are drawn. The default implementation aligns numbers to the right and other text to the left.

int QTableItem::col () const

Returns the column where the item is located. If the cell spans multiple columns, this function returns the leftmost column.

int QTableItem::colSpan () const

Returns teh column span of the item, normally 1.

See also setSpan().

QWidget * QTableItem::createEditor () const [virtual]

This virtual function creates the editor with which the user can edit the cell. The default implementation creates a QLineEdit.

If the function returns 0, that the cell can not be edited.

The returned widget should preferably not be visible, and it should preferably have QTable::viewport() as parent.

If you reimplement this function, you probably also need to reimplement setContentFromEditor().

See also QTable::createEditor(), setContentFromEditor() and QTable::viewport().

QTableItem::EditType QTableItem::editType() const

Returns the edit type of an item.

See also EditType.

bool QTableItem::isReplaceable () const

This function returns whether the relevant QTableItem can be replaced or not. Only items that cover no more than one cell might be replaced.

See also setReplaceable().

QString QTableItem::key () const [virtual]

This virtual function returns the key that should be used for sorting. The default implementation returns the text() of the relevant item.

void QTableItem::paint ( QPainter * p, const QColorGroup & cg, const QRect & cr, bool selected ) [virtual]

In order to paint the contents of an item call QTableItem::paint().

QPixmap QTableItem::pixmap () const [virtual]

Returns the item's pixmap.

int QTableItem::row () const

Returns the row where the item is located. If the cell spans multiple rows, this function returns the top row.

int QTableItem::rowSpan () const

Returns the row span of an item, normally 1.

See also setSpan().

void QTableItem::setCol ( int c ) [virtual]

Sets the item's column to be c. Normally you will not need to call this function.

If the cell spans multiple columns, this function sets the leftmost column and retains the width.

void QTableItem::setContentFromEditor ( QWidget * w ) [virtual]

Whenever the content of a cell has been edited by the editor w, QTable calls this virtual function to copy the new values into the QTableItem.

You probably must reimplement this function if you reimplement createEditor() and return something that is not a QLineEdit.

See also QTable::setContentFromEditor().

void QTableItem::setPixmap ( const QPixmap & p ) [virtual]

Sets the item pixmap to pix. QTableItem::setPixmap(), however, does not repaint the cell.

void QTableItem::setReplaceable ( bool b ) [virtual]

If it shouldn't be possible to replace the contents of the relevant cell with those of another QTableItem, set b to FALSE.

void QTableItem::setRow ( int r ) [virtual]

Sets the item's row to be row. Normally you will not need to call this function.

If the cell spans multiple rows, this function sets the top row and retains the height.

void QTableItem::setSpan ( int rs, int cs ) [virtual]

Creates a multi-cell QTableItem covering rs rows and cs columns. The top left corner of the item is at the item's former position.

Warning: This function only works, if the item has already been inserted into the table using e.g. QTable::setItem().

void QTableItem::setText ( const QString & str ) [virtual]

Changes the text of the item to str. Note that the cell is not repainted.

void QTableItem::setWordWrap ( bool b ) [virtual]

If b is TRUE, the cell's text is wrapped into multiple lines, otherwise it will be written on one line.

QSize QTableItem::sizeHint () const [virtual]

This virtual function returns the size a cell needs to show its entire content.

Many custom table items will need to reimplement this function.

QTable * QTableItem::table () const

Returns the QTable the item belongs to.

QString QTableItem::text () const [virtual]

Provides the text of the item.

bool QTableItem::wordWrap () const

If word wrap has been turned on for the cell in question, wordWrap() is TRUE, otherwise it returns FALSE.

void QTableItem::updateEditor ( int oldRow, int oldCol )

For internal use only.

Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):

This file is part of the Qt toolkit, copyright © 1995-2005 Trolltech, all rights reserved.

Copyright © 2005 TrolltechTrademarks
Qt version 2.3.10