The QListBox widget provides a single-column list of items that can be scrolled. More...
#include <qlistbox.h>
Inherits QTableView.
Each item in a QListBox contains a QListBoxItem. One of the items can be the current item. The highlighted() signal is emitted when the user highlights a new current item; selected() 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 StrongFocus
as a default focusPolicy(), i.e. it can
get keyboard focus both by tabbing and clicking.
New items may be inserted using either insertItem(), insertStrList() and inSort(). The list box is automatically updated to reflect the change; if you are going to insert a lot of data it may be worthwhile to wrap the insertion in calls to setAutoUpdate():
listBix->setAutoUpdate( FALSE ); for( i=1; i< hugeArray->count(); i++ ) listBox->insertItem( hugeArray[i] ); listBox->setAutoUpdate( TRUE ); listBox->repaint();
Each change to insertItem() normally causes a screen update, and for a large change only a few of those updates are really necessary. Be careful to call repaint() when you re-enable updates, so the widget is completely repainted.
By default, vertical and horizontal scroll bars are added and removed as necessary. setAutoScrollBar() can be used to force a specific 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 they are not needed.
See also: QListView, QComboBox, QButtonGroup and GUI Design Handbook: List Box (two sections)
Examples: widgets/widgets.cpp
Constructs a list box. The arguments are passed directly to the QTableView constructor.
Note that the f argument is not table flags but rather widget flags.
Destroys the list box. Deletes all list box items.
Returns TRUE if the list box has an automatic bottom scroll bar.
See also: setAutoBottomScrollBar() and autoScrollBar().
Returns TRUE if auto-scrolling is enabled, otherwise FALSE.
See also: setAutoScroll and dragSelect().
Returns TRUE if the list box has an automatic (vertical) scroll bar.
See also: setAutoScrollBar() and autoBottomScrollBar().
Returns TRUE if the list box updates itself automatically when items are inserted or removed.
The default setting is TRUE.
See also: setAutoUpdate().
Returns TRUE if the list box has a bottom scroll bar.
See also: setBottomScrollBar(), autoBottomScrollBar() and scrollBar().
[virtual protected]
Returns the height of the item at position index in pixels.
Reimplemented from QTableView.
Scrolls the list box so the current (highlighted) item is centered in the list box.
See also: currentItem() and setTopItem().
Replaces the item at posistion index with lbi. If index is negative or too large, changeItem() does nothing.
See also: insertItem() and removeItem().
Replaces the item at position index with pixmap.
The operation is ignored if index is out of range.
See also: insertItem() and removeItem().
Replaces the item at position index with text.
The operation is ignored if index is out of range.
See also: insertItem() and removeItem().
Deletes all items in the list.
See also: removeItem() and setStrList().
[protected]
Deletes all items in the list. Protected function that does NOT update the list box.
[slot]
Deselects all items. Note that a single-selection listbox will automatically select its first item if it has keyboard focus.
Returns the number of items in the list box.
Returns the index of the current (highlighted) item of the list box, or -1 if no item has been selected.
See also: topItem().
Returns TRUE if drag-selection is enabled, otherwise FALSE.
See also: setDragSelect() and autoScroll().
[protected]
Returns the index of the list box item at the vertical pixel-coordinate yPos.
See also: itemYPos().
[virtual protected]
Handles focus events. Repaints the current item (if not set, topItem() is made current).
See also: keyPressEvent() and focusOutEvent().
Reimplemented from QWidget.
[virtual protected]
Handles focus out events. Repaints the current item, if set.
See also: keyPressEvent() and focusOutEvent().
Reimplemented from QWidget.
[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().
[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().
Inserts lbi at its sorted position in the list box.
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().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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().
Examples: widgets/widgets.cpp
Inserts pixmap into the list at index.
If index is negative, pixmap is inserted at the end of the list.
See also: insertStrList().
Inserts text into the list at index.
If index is negative, text is inserted at the end of the list.
See also: insertStrList().
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.
See also: insertItem() and inSort().
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.
See also: insertItem() and inSort().
Returns TRUE if the listbox is in multi-selection mode, and FALSE if it is in single-selection mode.
See also: setMultiSelection().
Returns TRUE if item i is selected. Returns FALSE if it is not selected or if there is an error.
[protected]
Returns a pointer to the item at position index.
Returns the standard item height (in pixels), or -1 if the list box has variable item height.
Returns the height (in pixels) of item at index.
[protected]
Returns TRUE if the item at position index is at least partly visible.
[protected]
Returns the vertical pixel-coordinate in *yPos, of the list box item at position index in the list. Returns FALSE if the item is outside the visible area.
See also: findItem.
[virtual protected]
Handles key press events.
Up
and down
arrow keys make the highlighted item move and if
necessary scroll the list box.
Enter
makes the list box emit the selected() signal.
See also: selected() and setCurrentItem().
Reimplemented from QWidget.
For binary compatibility.
Returns the width in pixels of the widest item.
[virtual protected]
Handles mouse double click events. Emits the selected() signal for the item that was double-clicked.
Reimplemented from QWidget.
[virtual protected]
Handles mouse move events. Scrolls the list box if auto-scroll is enabled.
See also: autoScroll().
Reimplemented from QWidget.
[virtual protected]
Handles mouse press events. Makes the clicked item the current item.
See also: currentItem().
Reimplemented from QWidget.
[virtual protected]
Handles mouse release events.
Reimplemented from QWidget.
Returns the number of visible items. This may change at any time since the user may resize the widget.
See also: setFixedVisibleLines().
[virtual protected]
Repaints the cell at position row using p. The col argument is ignored, it is present because QTableView is more general. This function has the responsibility of showing focus and highlighting.
See also: QTableView::paintCell().
Reimplemented from QTableView.
Returns a pointer to the pixmap at position index, or 0 if there is no pixmap there.
See also: text().
Removes the item at position index. If index is equal to currentItem(), a new item gets selected and the highlighted() signal is emitted.
See also: insertItem() and clear().
[virtual protected]
Handles resize events. Updates internal parameters for the new list box size.
Reimplemented from QWidget.
Returns TRUE if the list box has a (vertical) scroll bar.
See also: setScrollBar(), autoScrollBar() and bottomScrollBar().
[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().
[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().
[signal]
This signal is emitted when the selection set of a multiple-choice listbox changes. 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().
Enables an automatic bottom scroll bar if enable is TRUE, or disables it if enable is FALSE.
If it is enabled, then the list box will get a bottom scroll bar if the maximum list box item width exceeds the list box width.
The default setting is TRUE.
See also: autoBottomScrollBar(), setBottomScrollBar() and setAutoScrollBar().
Sets auto-scrolling if enable is TRUE, or disables it if enable is FALSE.
If auto-scrolling is enabled, the list box will scroll its contents when the user drags the mouse outside (below or above) the list box. Auto-scrolling only works if drag-selection is enabled.
The default setting is TRUE.
See also: autoScroll() and setDragSelect().
Enables an automatic (vertical) scroll bar if enable is TRUE, or disables it if enable is FALSE.
If it is enabled, then the list box will get a (vertical) scroll bar if the list box items exceed the list box height.
The default setting is TRUE.
See also: autoScrollBar(), setScrollBar() and setAutoBottomScrollBar().
Specifies whether the list box should update itself automatically when items are inserted or removed.
Auto-update is enabled by default.
If enable is TRUE, the list box will update itself. If enable is FALSE, the list box will not update itself.
Warning: Do not leave the view in this state for a long time (i.e. between events ). If the user interacts with the view when auto-update is off, strange things can happen.
See also: autoUpdate().
Scrolls the list box so the item at position index in the list becomes the bottom row of the list box.
See also: setTopItem().
Enables a bottom scroll bar if enable is TRUE, or disables it if enable is FALSE.
The default setting is FALSE.
See also: bottomScrollBar(), setAutoBottomScrollBar() and setScrollBar().
Sets the highlighted item to the item at position index in the list. The highlighting is moved and the list box scrolled as necessary.
See also: currentItem().
Sets drag-selection if enable is TRUE, or disables it if enable is FALSE.
If drag-selection is enabled, the list box will highlight new items when the user drags the mouse inside the list box.
The default setting is TRUE.
See also: drawSelect() and setAutoScroll().
Sets a fixed height for the widget, so that it shows the given number of lines of text for the current font size.
[virtual]
Reimplements QWidget::setFont() to update the list box line height and maxItemWidth().
Reimplemented from QWidget.
Sets the list box to multi-selection mode if enable is TRUE, and to single-selection mode if enable is FALSE.
Single- and multi-selections modes work the same, except that the highlighted() and selected() signals are emitted at different times.
See also: isMultiSelection().
Enables a (vertical) scroll bar if enable is TRUE, or disables it if enable is FALSE.
The default setting is FALSE.
See also: scrollBar(), setAutoScrollBar() and setBottomScrollBar().
Selects the item at position index if select is TRUE, or unselects it if select is FALSE. May also repaint the item.
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().
Enables smooth list box scrolling if enable is TRUE, or disables it if enable is FALSE.
The default setting is TRUE.
See also: smoothScrolling().
Scrolls the list box so the item at position index in the list becomes the top row of the list box.
See also: topItem() and centerCurrentItem().
[virtual]
Returns a size mased on maxItemWidth() and any value set by setFixedVisibleLines().
Reimplemented from QWidget.
Returns TRUE if smooth list box scrolling is enabled, otherwise FALSE.
See also: setSmoothScrolling().
Returns a pointer to the text at position index, or 0 if there is no text there.
See also: pixmap().
[virtual protected]
Handles timer events. Does auto-scrolling.
Reimplemented from QObject.
[protected]
Toggles the selection status of currentItem() and repaints, if the listbox is a multi-selection listbox.
Does nothing if the listbox is a single-selection listbox.
See also: setMultiSelection().
Returns index of the item that is on the top line of the list box.
See also: setTopItem() and currentItem().
[protected]
Traverses the list and finds an item with the maximum width, and updates the internal list box structures accordingly.
[protected]
Repaints the item at position index in the list. Erases the line first if erase is TRUE.
Search the documentation, FAQ, qt-interest archive and more (uses
www.troll.no):
This file is part of the Qt toolkit, copyright © 1995-98 Troll Tech, all rights reserved.
It was generated from the following files:
Copyright © 1998 Troll Tech | Trademarks | Qt version 1.42
|