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

QListBox Class Reference

The QListBox widget provides a list of selectable, read-only items. More...

#include <QListBox>

This class is part of the Qt 3 compatibility library. It is provided to keep old source code working. We strongly advise against using it in new code.

Inherits QScrollView.

Public Types

Writable Properties

Read-Only Properties

Public Functions

Public Slots

Signals

Static Public Members

Protected Functions


Detailed Description

The QListBox widget provides a list of selectable, read-only items.

This is typically a single-column list in which either no item or one item is selected, but it can also be used in many other ways.

QListBox will add scroll bars as necessary, but it isn't intended for really big lists. If you want more than a few thousand items, it's probably better to use a different widget mainly because the scroll bars won't provide very good navigation, but also because QListBox may become slow with huge lists. (See QListView and QTable for possible alternatives.)

There are a variety of selection modes described in the QListBox::SelectionMode documentation. The default is Single selection mode, but you can change it using setSelectionMode(). (setMultiSelection() is still provided for compatibility with Qt 1.x. We recommend using setSelectionMode() in all code.)

Because QListBox offers multiple selection it must display keyboard focus and selection state separately. Therefore there are functions both to set the selection state of an item, i.e. setSelected(), and to set which item displays keyboard focus, i.e. setCurrentItem().

The list box normally arranges its items in a single column and adds a vertical scroll bar if required. It is possible to have a different fixed number of columns (setColumnMode()), or as many columns as will fit in the list box's assigned screen space (setColumnMode(FitToWidth)), or to have a fixed number of rows (setRowMode()) or as many rows as will fit in the list box's assigned screen space (setRowMode(FitToHeight)). In all these cases QListBox will add scroll bars, as appropriate, in at least one direction.

If multiple rows are used, each row can be as high as necessary (the normal setting), or you can request that all items will have the same height by calling setVariableHeight(false). The same applies to a column's width, see setVariableWidth().

The QListBox's items are QListBoxItem objects. QListBox provides methods to insert new items as strings, as pixmaps, and as QListBoxItem * (insertItem() with various arguments), and to replace an existing item with a new string, pixmap or QListBoxItem (changeItem() with various arguments). You can also remove items singly with removeItem() or clear() the entire list box. Note that if you create a QListBoxItem yourself and insert it, QListBox takes ownership of the item.

You can also create a QListBoxItem, such as QListBoxText or QListBoxPixmap, with the list box as first parameter. The item will then append itself. When you delete an item it is automatically removed from the list box.

The list of items can be arbitrarily large; QListBox will add scroll bars if necessary. QListBox can display a single-column (the common case) or multiple-columns, and offers both single and multiple selection. QListBox does not support multiple-column items (but QListView and QTable do), or tree hierarchies (but QListView does).

The list box items can be accessed both as QListBoxItem objects (recommended) and using integer indexes (the original QListBox implementation used an array of strings internally, and the API still supports this mode of operation). Everything can be done using the new objects, and most things can be done using indexes.

Each item in a QListBox contains a QListBoxItem. One of the items can be the current item. The currentChanged() signal and the highlighted() signal are emitted when a new item becomes current, e.g. because the user clicks on it or QListBox::setCurrentItem() is called. The selected() signal is emitted when the user double-clicks on an item or presses Enter on the current item.

If the user does not select anything, no signals are emitted and currentItem() returns -1.

A list box has Qt::WheelFocus as a default focusPolicy(), i.e. it can get keyboard focus by tabbing, clicking and through the use of the mouse wheel.

New items can be inserted using insertItem(), insertStrList() or insertStringList().

By default, vertical and horizontal scroll bars are added and removed as necessary. setHScrollBarMode() and setVScrollBarMode() can be used to change this policy.

If you need to insert types other than strings and pixmaps, you must define new classes which inherit QListBoxItem.

Warning: The list box assumes ownership of all list box items and will delete them when it does not need them any more.

Screenshot in Motif style Screenshot in Windows style

GUI Design Handbook: List Box (two sections)

See also QListView, QComboBox, and QButtonGroup.


Member Type Documentation

typedef QListBox::ComparisonFlags

This typedef is used in QIconView's API for values that are OR'd combinations of StringComparisonMode values.

See also StringComparisonMode.

enum QListBox::LayoutMode

This enum type is used to specify how QListBox lays out its rows and columns.

QListBox::FixedNumberThere is a fixed number of rows (or columns).
QListBox::FitToWidthThere are as many columns as will fit on-screen.
QListBox::FitToHeightThere are as many rows as will fit on-screen.
QListBox::VariableThere are as many rows as are required by the column mode. (Or as many columns as required by the row mode.)

Example: When you call setRowMode(FitToHeight), columnMode() automatically becomes Variable to accommodate the row mode you've set.

enum QListBox::SelectionMode

This enumerated type is used by QListBox to indicate how it reacts to selection by the user.

QListBox::SingleWhen the user selects an item, any already-selected item becomes unselected and the user cannot unselect the selected item. This means that the user can never clear the selection, even though the selection may be cleared by the application programmer using QListBox::clearSelection().
QListBox::MultiWhen the user selects an item the selection status of that item is toggled and the other items are left alone.
QListBox::ExtendedWhen the user selects an item the selection is cleared and the new item selected. However, if the user presses the Ctrl key when clicking on an item, the clicked item gets toggled and all other items are left untouched. And if the user presses the Shift key while clicking on an item, all items between the current item and the clicked item get selected or unselected, depending on the state of the clicked item. Also, multiple items can be selected by dragging the mouse while the left mouse button is kept pressed.
QListBox::NoSelectionItems cannot be selected.

In other words, Single is a real single-selection list box, Multi is a real multi-selection list box, Extended is a list box in which users can select multiple items but usually want to select either just one or a range of contiguous items, and NoSelection is for a list box where the user can look but not touch.

enum QListBox::StringComparisonMode

This enum type is used to set the string comparison mode when searching for an item. We'll refer to the string being searched as the 'target' string.

QListBox::CaseSensitiveThe strings must match case sensitively.
QListBox::ExactMatchThe target and search strings must match exactly.
QListBox::BeginsWithThe target string begins with the search string.
QListBox::EndsWithThe target string ends with the search string.
QListBox::ContainsThe target string contains the search string.

If you OR these flags together (excluding CaseSensitive), the search criteria be applied in the following order: ExactMatch, BeginsWith, EndsWith, Contains.

Matching is case-insensitive unless CaseSensitive is set. CaseSensitive can be OR-ed with any combination of the other flags.

See also ComparisonFlags.


Property Documentation

columnMode : LayoutMode

This property holds the column layout mode for this list box.

setColumnMode() sets the layout mode and adjusts the number of displayed columns. The row layout mode automatically becomes Variable, unless the column mode is Variable.

Access functions:

See also setRowMode(), columnMode(), rowMode, and numColumns.

count : uint

This property holds the number of items in the list box.

Access functions:

currentItem : int

This property holds the current highlighted item.

When setting this property, the highlighting is moved to the item and the list box scrolled as necessary.

If no item is current, currentItem() returns -1.

Access functions:

currentText : QString

This property holds the text of the current item.

This is equivalent to text(currentItem()).

Access functions:

multiSelection : bool

This property holds whether or not the list box is in Multi selection mode.

Consider using the QListBox::selectionMode property instead of this property.

When setting this property, Multi selection mode is used if set to true and to Single selection mode if set to false.

When getting this property, true is returned if the list box is in Multi selection mode or Extended selection mode, and false if it is in Single selection mode or NoSelection mode.

Access functions:

See also selectionMode.

numColumns : int

This property holds the number of columns in the list box.

This is normally 1, but can be different if QListBox::columnMode or QListBox::rowMode has been set.

Access functions:

See also columnMode, rowMode, and numRows.

numItemsVisible : int

This property holds the number of visible items.

Both partially and entirely visible items are counted.

Access functions:

numRows : int

This property holds the number of rows in the list box.

This is equal to the number of items in the default single-column layout, but can be different.

Access functions:

See also columnMode, rowMode, and numColumns.

rowMode : LayoutMode

This property holds the row layout mode for this list box.

This property is normally Variable.

setRowMode() sets the layout mode and adjusts the number of displayed rows. The column layout mode automatically becomes Variable, unless the row mode is Variable.

Access functions:

See also columnMode and rowMode.

selectionMode : SelectionMode

This property holds the selection mode of the list box.

Sets the list box's selection mode, which may be one of Single (the default), Extended, Multi or NoSelection.

Access functions:

See also SelectionMode.

topItem : int

This property holds the index of an item at the top of the screen.

When getting this property and the listbox has multiple columns, an arbitrary item is selected and returned.

When setting this property, the list box is scrolled so the item at position index in the list is displayed in the top row of the list box.

Access functions:

variableHeight : bool

This property holds whether this list box has variable-height rows.

When the list box has variable-height rows (the default), each row is as high as the highest item in that row. When it has same-sized rows, all rows are as high as the highest item in the list box.

Access functions:

See also variableWidth.

variableWidth : bool

This property holds whether this list box has variable-width columns.

When the list box has variable-width columns, each column is as wide as the widest item in that column. When it has same-sized columns (the default), all columns are as wide as the widest item in the list box.

Access functions:

See also variableHeight.


Member Function Documentation

QListBox::QListBox ( QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0 )

Constructs a new empty list box called name and with parent parent and widget attributes f.

This constructor sets the WA_StaticContent and the Qt::WA_NoBackground attributes to boost performance when drawing QListBoxItems. This may be unsuitable for custom QListBoxItem classes, in which case Qt::WA_StaticContents and Qt::WA_NoBackground should be cleared on the viewport() after construction.

See also QWidget::clearWFlags().

QListBox::~QListBox ()

Destroys the list box. Deletes all list box items.

bool QListBox::autoBottomScrollBar () const

Use hScrollBarMode() instead.

bool QListBox::autoScroll () const

Use dragAutoScroll() instead;

bool QListBox::autoScrollBar () const

Use vScrollBarMode() instead.

bool QListBox::autoUpdate () const

Returns true. Qt always updates automatically.

bool QListBox::bottomScrollBar () const

Use hScrollBarMode() instead.

int QListBox::cellHeight ( int i ) const

Use itemHeight(i) instead.

int QListBox::cellHeight () const

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

Use itemHeight() instead.

int QListBox::cellWidth () const

Use maxItemWidth() instead.

int QListBox::cellWidth ( int i ) const

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

Use maxItemWidth(i) instead.

void QListBox::centerCurrentItem ()

If there is a current item, the list box is scrolled so that this item is displayed centered.

See also QListBox::ensureCurrentVisible().

void QListBox::changeItem ( const QListBoxItem * lbi, int index )

Replaces the item at position index with lbi. If index is negative or too large, changeItem() does nothing.

The item that has been changed will become selected.

See also insertItem() and removeItem().

void QListBox::changeItem ( const QString & text, int index )

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

Replaces the item at position index with a new list box text item with text text.

The operation is ignored if index is out of range.

See also insertItem() and removeItem().

void QListBox::changeItem ( const QPixmap & pixmap, int index )

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

Replaces the item at position index with a new list box pixmap item with pixmap pixmap.

The operation is ignored if index is out of range.

See also insertItem() and removeItem().

void QListBox::changeItem ( const QPixmap & pixmap, const QString & text, int index )

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

Replaces the item at position index with a new list box pixmap item with pixmap pixmap and text text.

The operation is ignored if index is out of range.

See also insertItem() and removeItem().

void QListBox::clear ()   [slot]

Deletes all the items in the list.

See also removeItem().

void QListBox::clearSelection ()   [virtual slot]

Deselects all items, if possible.

Note that a Single selection list box will automatically select an item if it has keyboard focus.

void QListBox::clicked ( QListBoxItem * item )   [signal]

This signal is emitted when the user clicks any mouse button. If item is not 0, the cursor is on item. If item is 0, the mouse cursor isn't on any item.

Note that you must not delete any QListBoxItem objects in slots connected to this signal.

void QListBox::clicked ( QListBoxItem * item, const QPoint & pnt )   [signal]

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

This signal is emitted when the user clicks any mouse button. If item is not 0, the cursor is on item. If item is 0, the mouse cursor isn't on any item.

pnt is the position of the mouse cursor in the global coordinate system (QMouseEvent::globalPos()). (If the click's press and release differs by a pixel or two, pnt is the position at release time.)

Note that you must not delete any QListBoxItem objects in slots connected to this signal.

void QListBox::contextMenuRequested ( QListBoxItem * item, const QPoint & pos )   [signal]

This signal is emitted when the user invokes a context menu with the right mouse button or with special system keys, with item being the item under the mouse cursor or the current item, respectively.

pos is the position for the context menu in the global coordinate system.

void QListBox::currentChanged ( QListBoxItem * item )   [signal]

This signal is emitted when the user makes a new item the current item. item is the new current list box item.

See also setCurrentItem() and currentItem().

void QListBox::doLayout () const   [protected]

This function does the hard layout work. You should never need to call it.

void QListBox::doubleClicked ( QListBoxItem * item )   [signal]

This signal is emitted whenever an item is double-clicked. It's emitted on the second button press, not the second button release. If item is not 0, the cursor is on item. If item is 0, the mouse cursor isn't on any item.

bool QListBox::dragSelect () const

Returns true. Dragging always selects.

void QListBox::ensureCurrentVisible ()   [virtual slot]

Ensures that the current item is visible.

QListBoxItem * QListBox::findItem ( const QString & text, ComparisonFlags compare = BeginsWith ) const

Finds the first list box item that has the text text and returns it, or returns 0 of no such item could be found. If ComparisonFlags are specified in compare then these flags are used, otherwise the default is a case-insensitive, "begins with" search.

See also Qt::StringComparisonFlags.

int QListBox::findItem ( int yPos ) const   [protected]

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

Use index(itemAt(yPos)) instead.

QListBoxItem * QListBox::firstItem () const

Returns the first item in this list box. If the list box is empty, returns 0.

void QListBox::highlighted ( int index )   [signal]

This signal is emitted when the user makes a new item the current item. index is the index of the new current item.

See also currentChanged(), selected(), currentItem(), and selectionChanged().

void QListBox::highlighted ( QListBoxItem * item )   [signal]

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

This signal is emitted when the user makes a new item the current item.

See also currentChanged(), selected(), currentItem(), and selectionChanged().

void QListBox::highlighted ( const QString & text )   [signal]

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

This signal is emitted when the user makes a new item the current item and the item is (or has) as string. The argument is the new current item's text.

See also currentChanged(), selected(), currentItem(), and selectionChanged().

int QListBox::inSort ( const QListBoxItem * lbi )

Using this method is quite inefficient. We suggest to use insertItem() for inserting and sort() afterwards.

Inserts lbi at its sorted position in the list box and returns the position.

All items must be inserted with inSort() to maintain the sorting order. inSort() treats any pixmap (or user-defined type) as lexicographically less than any string.

See also insertItem() and sort().

int QListBox::inSort ( const QString & text )

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

Using this method is quite inefficient. We suggest to use insertItem() for inserting and sort() afterwards.

Inserts a new item of text at its sorted position in the list box and returns the position.

All items must be inserted with inSort() to maintain the sorting order. inSort() treats any pixmap (or user-defined type) as lexicographically less than any string.

See also insertItem() and sort().

int QListBox::index ( const QListBoxItem * lbi ) const

Returns the index of lbi, or -1 if the item is not in this list box or lbi is 0.

See also item().

void QListBox::insertItem ( const QListBoxItem * lbi, int index = -1 )

Inserts the item lbi into the list at position index.

If index is negative or larger than the number of items in the list box, lbi is inserted at the end of the list.

See also insertStrList().

void QListBox::insertItem ( const QListBoxItem * lbi, const QListBoxItem * after )

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

Inserts the item lbi into the list after the item after, or at the beginning if after is 0.

See also insertStrList().

void QListBox::insertItem ( const QString & text, int index = -1 )

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

Inserts a new list box text item with the text text into the list at position index.

If index is negative, text is inserted at the end of the list.

See also insertStrList().

void QListBox::insertItem ( const QPixmap & pixmap, int index = -1 )

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

Inserts a new list box pixmap item with the pixmap pixmap into the list at position index.

If index is negative, pixmap is inserted at the end of the list.

See also insertStrList().

void QListBox::insertItem ( const QPixmap & pixmap, const QString & text, int index = -1 )

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

Inserts a new list box pixmap item with the pixmap pixmap and the text text into the list at position index.

If index is negative, pixmap is inserted at the end of the list.

See also insertStrList().

void QListBox::insertStrList ( const char ** strings, int numStrings = -1, int index = -1 )

Inserts the numStrings strings of the array strings into the list at position index.

If index is negative, insertStrList() inserts strings at the end of the list. If index is too large, the operation is ignored.

Warning: This function uses const char * rather than QString, so we recommend against using it. It is provided so that legacy code will continue to work, and so that programs that certainly will not need to handle code outside a single 8-bit locale can use it. See insertStringList() which uses real QStrings.

Warning: This function is never significantly faster than a loop around insertItem().

See also insertItem() and insertStringList().

void QListBox::insertStringList ( const QStringList & list, int index = -1 )

Inserts the string list list into the list at position index.

If index is negative, list is inserted at the end of the list. If index is too large, the operation is ignored.

Warning: This function is never significantly faster than a loop around insertItem().

See also insertItem() and insertStrList().

void QListBox::invertSelection ()   [virtual slot]

Inverts the selection. Only works in Multi and Extended selection mode.

bool QListBox::isRubberSelecting () const   [protected]

Returns true if the user is selecting items using a rubber band rectangle; otherwise returns false.

bool QListBox::isSelected ( int i ) const

Returns true if item i is selected; otherwise returns false.

bool QListBox::isSelected ( const QListBoxItem * i ) const

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

Returns true if item i is selected; otherwise returns false.

QListBoxItem * QListBox::item ( int index ) const

Returns a pointer to the item at position index, or 0 if index is out of bounds.

See also index().

QListBoxItem * QListBox::itemAt ( const QPoint & p ) const

Returns the item at point p, which is in on-screen coordinates, or a 0 if there is no item at p.

int QListBox::itemHeight ( int index = 0 ) const

Returns the height in pixels of the item with index index. index defaults to 0.

If index is too large, this function returns 0.

QRect QListBox::itemRect ( QListBoxItem * item ) const

Returns the rectangle on the screen that item occupies in viewport()'s coordinates, or an invalid rectangle if item is 0 or is not currently visible.

bool QListBox::itemVisible ( int index )

Returns true if the item at position index is at least partly visible; otherwise returns false.

bool QListBox::itemVisible ( const QListBoxItem * item )

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

Returns true if item is at least partly visible; otherwise returns false.

long QListBox::maxItemWidth () const

Returns the width of the widest item in the list box.

void QListBox::mouseButtonClicked ( int button, QListBoxItem * item, const QPoint & pos )   [signal]

This signal is emitted when the user clicks mouse button button. If item is not 0, the cursor is on item. If item is 0, the mouse cursor isn't on any item.

pos is the position of the mouse cursor in the global coordinate system (QMouseEvent::globalPos()). (If the click's press and release differs by a pixel or two, pos is the position at release time.)

Note that you must not delete any QListBoxItem objects in slots connected to this signal.

void QListBox::mouseButtonPressed ( int button, QListBoxItem * item, const QPoint & pos )   [signal]

This signal is emitted when the user presses mouse button button. If item is not 0, the cursor is on item. If item is 0, the mouse cursor isn't on any item.

pos is the position of the mouse cursor in the global coordinate system (QMouseEvent::globalPos()).

Note that you must not delete any QListBoxItem objects in slots connected to this signal.

int QListBox::numCols () const

Use numColumns() instead.

void QListBox::onItem ( QListBoxItem * i )   [signal]

This signal is emitted when the user moves the mouse cursor onto an item, similar to the QWidget::enterEvent() function. i is the QListBoxItem that the mouse has moved on.

void QListBox::onViewport ()   [signal]

This signal is emitted when the user moves the mouse cursor from an item to an empty part of the list box.

void QListBox::paintCell ( QPainter * p, int row, int col )   [virtual protected]

Provided for compatibility with the old QListBox. We recommend using QListBoxItem::paint() instead.

Repaints the cell at row, col using painter p.

const QPixmap * QListBox::pixmap ( int index ) const

Returns a pointer to the pixmap at position index, or 0 if there is no pixmap there.

See also text().

void QListBox::pressed ( QListBoxItem * item )   [signal]

This signal is emitted when the user presses any mouse button. If item is not 0, the cursor is on item. If item is 0, the mouse cursor isn't on any item.

Note that you must not delete any QListBoxItem objects in slots connected to this signal.

void QListBox::pressed ( QListBoxItem * item, const QPoint & pnt )   [signal]

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

This signal is emitted when the user presses any mouse button. If item is not 0, the cursor is on item. If item is 0, the mouse cursor isn't on any item.

pnt is the position of the mouse cursor in the global coordinate system (QMouseEvent::globalPos()).

Note that you must not delete any QListBoxItem objects in slots connected to this signal.

See also mouseButtonPressed(), rightButtonPressed(), and clicked().

void QListBox::removeItem ( int index )

Removes and deletes the item at position index. If index is equal to currentItem(), a new item becomes current and the currentChanged() and highlighted() signals are emitted.

See also insertItem() and clear().

void QListBox::returnPressed ( QListBoxItem * item )   [signal]

This signal is emitted when Enter or Return is pressed. The item passed in the argument is currentItem().

void QListBox::rightButtonClicked ( QListBoxItem * item, const QPoint & point )   [signal]

This signal is emitted when the right button is clicked. The item is the item that the button was clicked on (which could be 0 if no item was clicked on), and the point is where the click took place in global coordinates.

void QListBox::rightButtonPressed ( QListBoxItem * item, const QPoint & point )   [signal]

This signal is emitted when the right button is pressed. The item is the item that the button was pressed over (which could be 0 if no item was pressed over), and the point is where the press took place in global coordinates.

bool QListBox::scrollBar () const

Use vScrollBarMode() instead.

void QListBox::selectAll ( bool select )   [virtual slot]

In Multi and Extended modes, this function sets all items to be selected if select is true, and to be unselected if select is false.

In Single and NoSelection modes, this function only changes the selection status of currentItem().

void QListBox::selected ( int index )   [signal]

This signal is emitted when the user double-clicks on an item or presses Enter on the current item. index is the index of the selected item.

See also currentChanged(), highlighted(), and selectionChanged().

void QListBox::selected ( QListBoxItem * item )   [signal]

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

This signal is emitted when the user double-clicks on an item or presses Enter on the current item.

See also currentChanged(), highlighted(), and selectionChanged().

void QListBox::selected ( const QString & text )   [signal]

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

This signal is emitted when the user double-clicks on an item or presses Enter on the current item, and the item is (or has) a string. The argument is the text of the selected item.

See also currentChanged(), highlighted(), and selectionChanged().

QListBoxItem * QListBox::selectedItem () const

Returns the selected item if the list box is in single-selection mode and an item is selected.

If no items are selected or the list box is in another selection mode this function returns 0.

See also setSelected() and setMultiSelection().

void QListBox::selectionChanged ()   [signal]

This signal is emitted when the selection set of a list box changes. This signal is emitted in each selection mode. If the user selects five items by drag-selecting, QListBox tries to emit just one selectionChanged() signal so the signal can be connected to computationally expensive slots.

See also selected() and currentItem().

void QListBox::selectionChanged ( QListBoxItem * item )   [signal]

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

This signal is emitted when the selection in a Single selection list box changes. item is the newly selected list box item.

See also selected() and currentItem().

void QListBox::setAutoBottomScrollBar ( bool enable )

Use setHScrollBarMode() instead.

If enable is true, pass Auto as the argument to setHScrollBarMode(); otherwise, pass AlwaysOff.

void QListBox::setAutoScroll ( bool b )

Use setDragAutoScroll(b) instead.

void QListBox::setAutoScrollBar ( bool enable )

Use setVScrollBarMode() instead.

If enable is true, pass Auto as the argument to setVScrollBarMode(); otherwise, pass AlwaysOff.

void QListBox::setAutoUpdate ( bool b )

Does nothing. Qt always updates automatically. The b parameter is ignored.

void QListBox::setBottomItem ( int index )   [virtual]

Scrolls the list box so the item at position index in the list is displayed in the bottom row of the list box.

See also setTopItem().

void QListBox::setBottomScrollBar ( bool enable )

Use setHScrollBarMode() instead.

If enable is true, pass AlwaysOn as the argument to setHScrollBarMode(); otherwise, pass AlwaysOff.

void QListBox::setDragSelect ( bool b )

Does nothing. Dragging always selects. The b parameter is ignored.

void QListBox::setFixedVisibleLines ( int lines )

Use setRowMode(lines) instead.

void QListBox::setScrollBar ( bool enable )

Use setVScrollBarMode() instead.

If enable is true, pass AlwaysOn as the argument to setVScrollBarMode(); otherwise, pass AlwaysOff.

void QListBox::setSelected ( QListBoxItem * item, bool select )   [virtual]

Selects item if select is true or unselects it if select is false, and repaints the item appropriately.

If the list box is a Single selection list box and select is true, setSelected() calls setCurrentItem().

If the list box is a Single selection list box, select is false, setSelected() calls clearSelection().

See also setMultiSelection(), setCurrentItem(), clearSelection(), and currentItem().

void QListBox::setSelected ( int index, bool select )

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

If select is true the item at position index is selected; otherwise the item is deselected.

void QListBox::setSmoothScrolling ( bool b )

Does nothing. Qt always scrolls smoothly. The b parameter is ignored.

bool QListBox::smoothScrolling () const

Returns false. Qt always scrolls smoothly.

void QListBox::sort ( bool ascending = true )

If ascending is true sorts the items in ascending order; otherwise sorts in descending order.

To compare the items, the text (QListBoxItem::text()) of the items is used.

void QListBox::takeItem ( const QListBoxItem * item )

Removes item from the list box and causes an update of the screen display. The item is not deleted. You should normally not need to call this function because QListBoxItem::~QListBoxItem() calls it. The normal way to delete an item is with delete.

See also QListBox::insertItem().

QString QListBox::text ( int index ) const

Returns the text at position index, or an empty string if there is no text at that position.

See also pixmap().

void QListBox::toggleCurrentItem ()   [protected]

Toggles the selection status of currentItem() and repaints if the list box is a Multi selection list box.

See also setMultiSelection().

int QListBox::totalHeight () const   [protected]

Use contentsHeight() instead.

int QListBox::totalWidth () const   [protected]

Use contentsWidth() instead.

void QListBox::triggerUpdate ( bool doLayout )

Ensures that a single paint event will occur at the end of the current event loop iteration. If doLayout is true, the layout is also redone.

void QListBox::updateCellWidth ()   [protected]

Does nothing. Qt automatically updates.

void QListBox::updateItem ( int index )   [protected]

Repaints the item at position index in the list.

void QListBox::updateItem ( QListBoxItem * i )   [protected]

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

Repaints the QListBoxItem i.


Copyright © 2004 Trolltech. Trademarks
Qt 4.0.0-tp2