Qt Reference Documentation

Q3ComboTableItem Class Reference

The Q3ComboTableItem class provides a means of using comboboxes in Q3Tables. More...

 #include <Q3ComboTableItem>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Inherits Q3TableItem.

Public Functions

Q3ComboTableItem ( Q3Table * table, const QStringList & list, bool editable = false )
~Q3ComboTableItem ()
int count () const
int currentItem () const
QString currentText () const
bool isEditable () const
virtual void setCurrentItem ( int i )
virtual void setCurrentItem ( const QString & s )
virtual void setEditable ( bool b )
virtual void setStringList ( const QStringList & l )
QString text ( int i ) const

Reimplemented Public Functions

virtual QWidget * createEditor () const
virtual void paint ( QPainter * p, const QColorGroup & cg, const QRect & cr, bool selected )
virtual int rtti () const
virtual void setContentFromEditor ( QWidget * w )
virtual QSize sizeHint () const
virtual QString text () const

Detailed Description

The Q3ComboTableItem class provides a means of using comboboxes in Q3Tables.

A Q3ComboTableItem is a table item which looks and behaves like a combobox. The advantage of using Q3ComboTableItems rather than real comboboxes is that a Q3ComboTableItem uses far less resources than real comboboxes in Q3Tables. 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 Q3ComboTableItems.

Q3ComboTableItem items have the edit type WhenCurrent (see EditType). The Q3ComboTableItem's list of items is provided by a QStringList 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 Q3ComboTableItem 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 Q3ComboTableItem use Q3Table::setItem().

Q3ComboTableItems may be deleted with Q3Table::clearCell().

Q3ComboTableItems can be distinguished from Q3TableItems and Q3CheckTableItems using their Run Time Type Identification number (see rtti()).

Table Items

See also Q3CheckTableItem, Q3TableItem, and Q3ComboBox.

Member Function Documentation

Q3ComboTableItem::Q3ComboTableItem ( Q3Table * table, const QStringList & 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 Q3ComboTableItems cannot be replaced by other table items since isReplaceable() returns false by default.

See also Q3Table::clearCell() and EditType.

Q3ComboTableItem::~Q3ComboTableItem ()

Q3ComboTableItem destructor.

int Q3ComboTableItem::count () const

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

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

Reimplemented from Q3TableItem::createEditor().

int Q3ComboTableItem::currentItem () const

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

See also setCurrentItem().

QString Q3ComboTableItem::currentText () const

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

See also currentItem() and text().

bool Q3ComboTableItem::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().

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

Reimplemented from Q3TableItem::paint().

int Q3ComboTableItem::rtti () const [virtual]

Reimplemented from Q3TableItem::rtti().

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 Q3TableItem::rtti().

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

Reimplemented from Q3TableItem::setContentFromEditor().

void Q3ComboTableItem::setCurrentItem ( int i ) [virtual]

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

See also currentItem().

void Q3ComboTableItem::setCurrentItem ( const QString & s ) [virtual]

This is an overloaded 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 Q3ComboTableItem::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 Q3ComboTableItem::setStringList ( const QStringList & l ) [virtual]

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

QSize Q3ComboTableItem::sizeHint () const [virtual]

Reimplemented from Q3TableItem::sizeHint().

QString Q3ComboTableItem::text () const [virtual]

Reimplemented from Q3TableItem::text().

Returns the text of the table item or an empty string if there is no text.

See also Q3TableItem::text().

QString Q3ComboTableItem::text ( int i ) const

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

See also currentText().

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.