Classes - Annotated - Tree - Functions - Home - Structure

QCheckTableItem Class Reference
[table module]

The QCheckTableItem class provides checkboxes in QTables. More...

#include <qtable.h>

Inherits QTableItem.

List of all member functions.

Public Members


Detailed Description

The QCheckTableItem class provides checkboxes in QTables.

To fill a table cell with a checkbox instead of the usual text or pixmap create a QCheckTableItem object and use QTable::setItem() to make it the contents of a table cell.

The QCheckTableItem is not a real checkbox, but paints itself to look like one. When the focus is in the QCheckTableItem cell a checkbox that the user can interact with is displayed. The QCheckTableItem provides the appearance and functionality of a checkbox but without the overhead of every cell actually being a checkbox.

QCheckTableItems have the edit type WhenCurrent. To change the checkbox's label use setText(). The checkbox can be checked and unchecked with setChecked() and its state retrieved using isChecked(). Check box items cannot include a pixmap.

QCheckTableItems can be distinguished from QTableItems and QComboTableItems using their Run Time Type Identification (rtti) number.

See also rtti() and EditType.


Member Function Documentation

QCheckTableItem::QCheckTableItem ( QTable * table, const QString & txt )

Creates a QCheckTableItem with an EditType of WhenCurrent as a child of table. The checkbox's label is set to the string txt. Example:

        QTable table( numRows, numCols );
            table.setItem( j, 1, new QCheckTableItem( &table, "Check me" ) );

(Code taken from table/small-table-demo/main.cpp).

By default QCheckTableItem objects are unchecked. To check them use setChecked(). The text can be changed using setText().

QTable::setItem() makes checkbox items the contents of a QTable that may or may not be the item's parent. It is not possible to use a QCheckTableItem in more than one table at a time.

bool QCheckTableItem::isChecked () const

Returns whether the item is checked.

See also setChecked().

int QCheckTableItem::rtti () const [virtual]

Returns 2.

Make your derived classes return their own values for rtti(), and you can distinguish between table items. You should use values greater than 1000 preferably a large random number, to allow for extensions to this class.

See also QTableItem::rtti().

Reimplemented from QTableItem.

void QCheckTableItem::setChecked ( bool b ) [virtual]

If b is TRUE the checkbox is checked; if b is FALSE the checkbox is unchecked.

See also isChecked().


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


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


Copyright © 2000 TrolltechTrademarks
Qt version main-beta1