TQComboTableItem Class

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

# TQComboTableItem Class Reference
[table module]

The TQComboTableItem class provides a means of using comboboxes in TQTables. More...

`#include <ntqtable.h>`

Inherits TQTableItem.

List of all member functions.

## Public Members

- TQComboTableItem ( TQTable * table, const TQStringList & list, bool editable = false )
- ~TQComboTableItem ()
- virtual void setCurrentItem ( int i )
- virtual void setCurrentItem ( const TQString & s )
- int currentItem () const
- TQString currentText () const
- int count () const
- TQString text ( int i ) const
- virtual void setEditable ( bool b )
- bool isEditable () const
- virtual void setStringList ( const TQStringList & l )
- virtual int rtti () const

## Detailed Description

The TQComboTableItem class provides a means of using comboboxes in TQTables.

A TQComboTableItem is a table item which looks and behaves like a combobox. The advantage of using TQComboTableItems rather than real comboboxes is that a TQComboTableItem uses far less resources than real comboboxes in TQTables. When the cell has the focus it displays a real combobox which the user can interact with. When the cell does not have the focus the cell looks like a combobox. Only text items (i.e. no pixmaps) may be used in TQComboTableItems.

TQComboTableItem items have the edit type WhenCurrent (see EditType). The TQComboTableItem's list of items is provided by a TQStringList passed to the constructor.

The list of items may be changed using setStringList(). The current item can be set with setCurrentItem() and retrieved with currentItem(). The text of the current item can be obtained with currentText(), and the text of a particular item can be retrieved with text().

If isEditable() is true the TQComboTableItem will permit the user to either choose an existing list item, or create a new list item by entering their own text; otherwise the user may only choose one of the existing list items.

To populate a table cell with a TQComboTableItem use TQTable::setItem().

TQComboTableItems may be deleted with TQTable::clearCell().

TQComboTableItems can be distinguished from TQTableItems and TQCheckTableItems using their Run Time Type Identification number (see rtti()).

See also TQCheckTableItem, TQTableItem, TQComboBox, and Advanced Widgets.

## Member Function Documentation

### TQComboTableItem::TQComboTableItem ( TQTable * table, const TQStringList & list, bool editable = false )

Creates a combo table item for the table table. The combobox's list of items is passed in the list argument. If editable is true the user may type in new list items; if editable is false the user may only select from the list of items provided.

By default TQComboTableItems cannot be replaced by other table items since isReplaceable() returns false by default.

See also TQTable::clearCell() and EditType.

### TQComboTableItem::~TQComboTableItem ()

TQComboTableItem destructor.

### int TQComboTableItem::count () const

Returns the total number of list items in the combo table item.

### int TQComboTableItem::currentItem () const

Returns the index of the combo table item's current list item.

See also setCurrentItem().

### TQString TQComboTableItem::currentText () const

Returns the text of the combo table item's current list item.

See also currentItem() and text().

### bool TQComboTableItem::isEditable () const

Returns true if the user can add their own list items to the combobox's list of items; otherwise returns false.

See also setEditable().

### int TQComboTableItem::rtti () const`[virtual]`

Returns 1.

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

See also TQTableItem::rtti().

Reimplemented from TQTableItem.

### void TQComboTableItem::setCurrentItem ( int i )`[virtual]`

Sets the list item i to be the combo table item's current list item.

See also currentItem().

Example: table/small-table-demo/main.cpp.

### void TQComboTableItem::setCurrentItem ( const TQString & s )`[virtual]`

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the list item whose text is s to be the combo table item's current list item. Does nothing if no list item has the text s.

See also currentItem().

### void TQComboTableItem::setEditable ( bool b )`[virtual]`

If b is true the combo table item can be edited, i.e. the user may enter a new text item themselves. If b is false the user may may only choose one of the existing items.

See also isEditable().

### void TQComboTableItem::setStringList ( const TQStringList & l )`[virtual]`

Sets the list items of this TQComboTableItem to the strings in the string list l.

### TQString TQComboTableItem::text ( int i ) const

Returns the text of the combo's list item at index i.

See also currentText().

This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.