HomeHome

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

QListBox Class Reference


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

#include <qlistbox.h>

Inherits QScrollView.

List of all member functions.

Public Members

Public Slots

Signals

Protected Members

Protected Slots

Properties

TypeNameREADWRITEOptions
uintcountcount  
intnumItemsVisiblenumItemsVisible  
intcurrentItemcurrentItemsetCurrentItem DESIGNABLE false
QStringcurrentTextcurrentText  
inttopItemtopItemsetTopItem DESIGNABLE false
SelectionModeselectionModeselectionModesetSelectionMode 
boolmultiSelectionisMultiSelectionsetMultiSelection DESIGNABLE false
LayoutModecolumnModecolumnModesetColumnMode 
LayoutModerowModerowModesetRowMode 
intnumColumnsnumColumns  
intnumRowsnumRows  
boolvariableWidthvariableWidthsetVariableWidth 
boolvariableHeightvariableHeightsetVariableHeight 

Detailed Description

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

This is typically a single-column list where zero or one items are selected at once, but can also be used in many other ways.

QListBox will add scroll bars as necessary, but 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, chiefly because the scroll bars won't provide very good navigation, but also because QListBox may become slow at larger sizes.

There is a variety of selection modes, described in the QListBox::SelectionMode documentation. The default is single-selection, and you can change it using setSelectionMode(). For compatibility with previous Qt versions there is still the setMultiSelection() methode. Calling setMultiSelection( TRUE ) is equivalent to setSelectionMode( Multi ), and setMultiSelection( FALSE ) is equivalent to setSelectionMode( Single ). It's suggested not to use setMultiSelection() anymore, but to use setSelectionMode() instead.

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

The list box normally arranges its items in a single column with a vertical scroll bar if necessary, but it is also possible to have a different fixed number of columns (setColumnMode()), or as many columns as will fit in the list box' 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' assigned screen space (setRowMode( FitToHeight )). In all these cases, QListBox will add scroll bars as appropriate in at least one direction.

If multiple rows is 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 ). Of course there is a similar setVariableWidth().

The items discussed are QListBoxItem objects. QListBox provides methods to insert new items as a string, 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 (surprise: removeItem()) and clear() the entire list box. Note that if you create a QListBoxItem yourself and insert it, it becomes the property of QListBox and you may not delete it. (QListBox will delete it when appropriate.)

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 listbox.

The list of items can be arbitrarily big; if necessary, QListBox adds scroll bars. It can be single-column (as most list boxes are) or multi-column, and offers both single and multiple selection. (QListBox does however not support multiple-column items; QListView does that job.) Also a listbox can display items arranged in a tree. But this is quite limited, and if you really want to display and work with a tree, you should use a QListView. The tree stuff in the QListBox is only supported because it´s needed in comboboxes.

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; most things can be done using the indexes too but unfortunately not everything.

Each item in a QListBox contains a QListBoxItem. One of the items can be the current item. The highlighted() signal is emitted when a new item gets highlighted, 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 return when an item is highlighted.

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

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

New items may be inserted using either insertItem(), insertStrList() or insertStringList(). inSort() is obsolete, as this method is quite inefficient. It's preferable to insert the items normally and call sort() afterwards, or insert a sorted QStringList().

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 other types than texts 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.

See also QListView, QComboBox, QButtonGroup and GUI Design Handbook: List Box (two sections)


Member Type Documentation

QListBox::LayoutMode

This enum type decides how QListBox lays out its rows and columns. The two modes interact, of course.

The possible values for each mode are:

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

QListBox::SelectionMode

This enumerated type is used by QListBox to indicate how it reacts to selection by the user. It has four values:

In other words, Single is a real single-selection list box, Multi a real multi-selection list box, and Extended list box where 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.


Member Function Documentation

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

Constructs a new empty list box, with parent as a parent and name as object name.

Performance is boosted by modifying the widget flags f so that only part of the QListBoxItem children is redrawn. This may be unsuitable for custom QListBoxItem classes, in which case WNorthWestGravity and WRepaintNoErase should be cleared.

See also QWidget::clearWFlags() and Qt::WidgetFlags.

QListBox::~QListBox ()

Destroys the list box. Deletes all list box items.

void QListBox::centerCurrentItem ()

If there is a current item, the listbox 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.

See also insertItem() and removeItem().

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

Replaces the item at position index with pixmap and text.

The operation is ignored if index is out of range.

See also insertItem() and removeItem().

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

Replaces the item at position index with pixmap.

The operation is ignored if index is out of range.

See also insertItem() and removeItem().

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

Replaces the item at position index with text.

The operation is ignored if index is out of range.

See also insertItem() and removeItem().

void QListBox::clear ()

Deletes all items in the list.

See also removeItem().

void QListBox::clearSelection () [virtual slot]

Deselects all items, if possible.

Note that a single-selection listbox will automatically select an item if it has keyboard focus.

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

This signal is emitted whenever the user clicks (mouse pressed + mouse released) into the listbox. item is the pointer to the clicked listbox item or NULL, if the user didn't click on an item.

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

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

This signal is emitted whenever the user clicks (mouse pressed + mouse released) into the listbox. item is the pointer to the clicked listbox item or NULL, if the user didn't click on an item. pnt is the position where the user has clicked.

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

QListBox::LayoutMode QListBox::columnMode() const

Returns the column layout mode for this list box. This is normally FixedNumber, but can be changed by calling setColumnMode()

See also rowMode(), setColumnMode() and numColumns().

uint QListBox::count () const

Returns the number of items in the list box.

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

This signal is emitted when the user highlights a new current item. The argument is the index of the new item, which is already current.

See also setCurrentItem() and currentItem().

int QListBox::currentItem () const

Returns the index of the current (highlighted) item of the list box, or -1 if no item has been selected.

See also topItem().

QString QListBox::currentText () const

Returns the text of the current item.

This is equivalent to text(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. item is the listbox item onto which the user did the double click.

void QListBox::ensureCurrentVisible () [virtual slot]

Ensures that the current item is visible.

QListBoxItem * QListBox::findItem ( const QString & text ) const

Finds the first listbox item which starts with text and returns it, or returns 0 of no such item could be found. The search is done case-insensitive.

QListBoxItem * QListBox::firstItem () const

Returns the first item of this listbox.

void QListBox::focusInEvent ( QFocusEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QListBox::focusOutEvent ( QFocusEvent * ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

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

This signal is emitted when the user highlights a new current item. The argument is a pointer to the new current item.

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

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

This signal is emitted when the user highlights a new current item and the new item is a string. The argument is the text of the new current item.

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

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

This signal is emitted when the user highlights a new current item. The argument is the index of the new item, which is already current.

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

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 a NULL-Pointer.

See also item().

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

Inserts the item lbi into the list after the item after.

If after is NULL, lbi is inserted at the beginning.

See also insertStrList().

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

Inserts the item lbi into the list at 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 QPixmap & pixmap, const QString & text, int index=-1 )

Inserts pixmap and text into the list at index.

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

See also insertStrList().

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

Inserts pixmap into the list at index.

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

See also insertStrList().

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

Inserts text into the list at index.

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

See also insertStrList().

void QListBox::insertStrList ( const QStrList & list, int index=-1 )

Inserts the string list list into the list at item 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 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() - it uses real QStrings.

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

See also insertItem() and insertStringList().

void QListBox::insertStrList ( const QStrList * list, int index=-1 )

Inserts the string list list into the list at item 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 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() - it uses real QStrings.

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

See also insertItem() and insertStringList().

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

Inserts the numStrings strings of the array strings into the list at itemindex.

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() - it 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 item 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 () [slot]

Inverts the selection. Works only in Multi and Extended selection mode.

bool QListBox::isMultiSelection () const

This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.

Consider using selectionMode() instead of this method.

Returns TRUE if the listbox is in multi-selection mode or extended selection mode, and FALSE if it is in single-selection mode or no-selection more.

See also selectionMode() and setSelectionMode().

bool QListBox::isRubberSelecting () const [protected]

Returns whether the user is selecting items using a rubber rectangle.

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

Returns TRUE if item i is selected. Returns FALSE if it is not selected or if there is an error.

bool QListBox::isSelected ( int i ) const

Returns TRUE if item i is selected. Returns FALSE if it is not selected or if there is an error.

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 ( QPoint p ) const

Returns a pointer to the item at p, which is in on-screen coordinates, or a null pointer 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 item occupies in viewport()'s coordinates, or an invalid rectangle if item is a null pointer or is not currently visible.

bool QListBox::itemVisible ( const QListBoxItem * item )

Returns TRUE if item is at least partly visible, or else FALSE.

bool QListBox::itemVisible ( int index )

Returns TRUE if the item at position index is at least partly visible.

void QListBox::keyPressEvent ( QKeyEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

long QListBox::maxItemWidth () const

Returns the width of the largest item in the listbox.

QSize QListBox::minimumSizeHint () const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

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

This signal is emitted whenever the user clicks (mouse pressed + mouse released) into the listbox. button is the mouse button, which the user pressed. item is the pointer to the clicked listbox item or NULL, if the user didn't click on an item. pos is the position where the user has clicked.

Note that you may 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 whenever the user presses the mouse button on a listbox. button is the mouse button, which the user pressed. item is the pointer to the listbox item onto which the user pressed the mouse button or NULL, if the user didn't press the mouse on an item. pos is the position of the mouse cursor where the mouse cursor was when the user pressed the mouse button.

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

void QListBox::mouseDoubleClickEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QListBox::mouseMoveEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QListBox::mousePressEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QListBox::mouseReleaseEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

int QListBox::numColumns () const

Returns the number of columns in the list box. This is normally 1, but can be different if setColumnMode() or setRowMode() has been called.

See also setColumnMode(), setRowMode() and numRows().

int QListBox::numItemsVisible () const

Returns the number of visible items. Both partially and entirely visible items are counted.

int QListBox::numRows () const

Returns 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.

See also setRowMode() and numColumns().

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

This signal is emitted, when the user moves the mouse cursor onto an item. It´s only emitted once per item.

void QListBox::onViewport () [signal]

This signal is emitted, when the user moves the mouse cursor, which was on an item away from the item onto the viewport.

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

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

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 whenever the user presses the mouse button on a listbox. item is the pointer to the listbox item onto which the user pressed the mouse button or NULL, if the user didn't press the mouse on an item.

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

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

This signal is emitted whenever the user presses the mouse button on a listbox. item is the pointer to the listbox item onto which the user pressed the mouse button or NULL, if the user didn't press the mouse on an item. pnt is the position of the mouse cursor where the mouse cursor was when the user pressed the mouse button.

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

void QListBox::removeItem ( int index )

Removes and deletes the item at position index. If index is equal to currentItem(), a new item gets highlighted and the highlighted() signal is emitted.

See also insertItem() and clear().

void QListBox::resizeEvent ( QResizeEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

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

This signal is emitted when enter or return is pressed. The argument is currentItem().

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

This signal is emitted when the right button is clicked (ie. when it's released). The arguments are the relevant QListBoxItem (may be 0) and the point in global coordinates.

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

This signal is emitted when the right button is pressed. Then arguments are the relevant QListBoxItem (may be 0) and the point in global coordinates.

QListBox::LayoutMode QListBox::rowMode() const

Returns the row layout mode for this list box. This is normally Variable, but can be changed by calling setRowMode().

See also columnMode(), setRowMode() and numRows().

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

If select is TRUE, all items get selected, else all get unselected. This works only in the selection modes Multi and Extended. In Single and NoSelection mode the selection of the current item is just set to select.

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

This signal is emitted when the user double-clicks on an item or presses return when an item is highlighted. The argument is a pointer to the new selected item.

See also highlighted() and selectionChanged().

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

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

See also highlighted() and selectionChanged().

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

This signal is emitted when the user double-clicks on an item or presses return when an item is highlighted. The argument is the index of the selected item.

See also highlighted() and selectionChanged().

void QListBox::selectionChanged () [signal]

This signal is emitted when the selection set of a listbox 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 signal is emitted when the selection in a single-selection listbox changes. item is the new selected listbox item.

See also selected() and currentItem().

QListBox::SelectionMode QListBox::selectionMode() const

Returns the selection mode of the list box. The initial mode is Single.

See also setSelectionMode().

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::setColumnMode ( LayoutMode mode )

Sets the column layout mode to mode, and the number of displayed columns accordingly.

The row layout mode implicitly becomes Variable.

If mode is Variable, this function returns without doing anything.

See also setRowMode() and columnMode().

void QListBox::setColumnMode ( int columns ) [virtual]

Sets the column layout mode for this list box to FixedNumber, and sets the number of displayed columns accordingly.

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

void QListBox::setCurrentItem ( QListBoxItem * i ) [virtual]

Sets the highlighted item to the item i. The highlighting is moved and the list box scrolled as necessary.

See also currentItem().

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This is a bit slower than the QListBoxItem * version.

void QListBox::setFont ( const QFont & font ) [virtual]

Reimplemented for internal reasons; the API is not affected.

void QListBox::setMultiSelection ( bool enable )

This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.

Consider using setSelectionMode() instead of this method.

Sets the list box to multi-selection mode if enable is TRUE, and to single-selection mode if enable is FALSE. We recommend using setSelectionMode() instead; that function also offers two other modes.

See also setSelectionMode() and selectionMode().

void QListBox::setRowMode ( LayoutMode mode )

Sets the row layout mode to mode, and the number of displayed rows accordingly.

The column layout mode implicitly becomes Variable.

If mode is Variable, this function returns without doing anything.

See also setColumnMode() and rowMode().

void QListBox::setRowMode ( int rows ) [virtual]

Sets the row layout mode for this list box to FixedNumber and sets the number of displayed rows accordingly.

See also setColumnMode(), rowMode() and numRows().

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 listbox is a single-selection listbox and and select is TRUE, setCurrentItem() is called.

If the listbox is a single-selection listbox and and select is FALSE, clearSelection() is called if item is the currently selected item.

Note that for this function, no-selection means multi-selection. The user cannot select items in a no-selection list box, but the application programmer can.

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

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

Selects the item at position index if select is TRUE, or unselects it if select is FALSE, and repaints the item appropriately.

If the listbox is a single-selection listbox and and select is TRUE, setCurrentItem() will be called.

If the listbox is a single-selection listbox and and select is FALSE, clearSelection() will be called if index is the currently selected item.

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

void QListBox::setSelectionMode ( SelectionMode mode )

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

See also selectionMode().

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

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

See also topItem() and ensureCurrentVisible().

void QListBox::setVariableHeight ( bool enable ) [virtual]

Sets this list box to have variable-height rows if enable is TRUE, and equal-height rows if enable is FALSE.

When the list box has variable-height rows, 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.

The default is TRUE.

See also setVariableWidth() and variableHeight().

void QListBox::setVariableWidth ( bool enable ) [virtual]

Sets this list box to have variable-width columns if enable is TRUE, and equal-width columns if enable is FALSE.

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, all columns are as wide as the widest item in the list box.

The default is FALSE.

See also setVariableHeight() and variableWidth().

void QListBox::showEvent ( QShowEvent * ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QSize QListBox::sizeHint () const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QListBox::sort ( bool ascending = TRUE )

Sorts the item in ascending order, if ascending is TRUE, or descending otherwise.

To compare the items, the text (QListBoxItem::text()) of the items is used. The sorting is done using the Quick-Sort Alogorithm.

void QListBox::takeItem ( const QListBoxItem * item )

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

See also QListBox::insertItem().

QString QListBox::text ( int index ) const

Returns the text at position index, or a null 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 listbox is a multi-selection listbox.

See also setMultiSelection().

int QListBox::topItem () const

Returns the index of an item at the top of the screen. If there are more than one of them, an arbitrary item is selected and returned.

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::updateItem ( QListBoxItem * i ) [protected]

Repaints i.

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

Repaints the item at position index in the list.

bool QListBox::variableHeight () const

Returns TRUE if this list box has variable-height rows, and FALSE if all the rows have the same height.

See also setVariableHeight() and setVariableWidth().

bool QListBox::variableWidth () const

Returns TRUE if this list box has variable-width columns, and FALSE if all the columns have the same width.

See also setVariableHeight() and setVariableWidth().

void QListBox::viewportMouseDoubleClickEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QScrollView.

void QListBox::viewportMouseMoveEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QScrollView.

void QListBox::viewportMousePressEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QScrollView.

void QListBox::viewportMouseReleaseEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QScrollView.

void QListBox::viewportPaintEvent ( QPaintEvent * e ) [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QScrollView.

void QListBox::clearInputString () [protected slot]

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