
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQ3ListBox widget provides a list of selectable, read-only items.More...
| Header: | #include <Q3ListBox> |
| Inherits: | Q3ScrollView |
| typedef | ComparisonFlags |
| enum | LayoutMode { FixedNumber, FitToWidth, FitToHeight, Variable } |
| enum | SelectionMode { Single, Multi, Extended, NoSelection } |
| enum | StringComparisonMode { CaseSensitive, ExactMatch, BeginsWith, EndsWith, Contains } |
|
|
| Q3ListBox(QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0) | |
| ~Q3ListBox() | |
| bool | autoBottomScrollBar() const |
| bool | autoScroll() const |
| bool | autoScrollBar() const |
| bool | autoUpdate() const |
| bool | bottomScrollBar() const |
| int | cellHeight(int i) const |
| int | cellHeight() const |
| int | cellWidth() const |
| int | cellWidth(int i) const |
| void | centerCurrentItem() |
| void | changeItem(const Q3ListBoxItem * lbi, int index) |
| void | changeItem(const QString & text, int index) |
| void | changeItem(const QPixmap & pixmap, int index) |
| void | changeItem(const QPixmap & pixmap, const QString & text, int index) |
| LayoutMode | columnMode() const |
| uint | count() const |
| int | currentItem() const |
| QString | currentText() const |
| bool | dragSelect() const |
| Q3ListBoxItem * | findItem(const QString & text, ComparisonFlags compare = BeginsWith) const |
| Q3ListBoxItem * | firstItem() const |
| int | inSort(const Q3ListBoxItem * lbi) |
| int | inSort(const QString & text) |
| int | index(const Q3ListBoxItem * lbi) const |
| void | insertItem(const Q3ListBoxItem * lbi, int index = -1) |
| void | insertItem(const Q3ListBoxItem * lbi, const Q3ListBoxItem * after) |
| void | insertItem(const QString & text, int index = -1) |
| void | insertItem(const QPixmap & pixmap, int index = -1) |
| void | insertItem(const QPixmap & pixmap, const QString & text, int index = -1) |
| void | insertStrList(const char ** strings, int numStrings = -1, int index = -1) |
| void | insertStringList(const QStringList & list, int index = -1) |
| bool | isMultiSelection() const |
| bool | isSelected(int i) const |
| bool | isSelected(const Q3ListBoxItem * i) const |
| Q3ListBoxItem * | item(int index) const |
| Q3ListBoxItem * | itemAt(const QPoint & p) const |
| int | itemHeight(int index = 0) const |
| QRect | itemRect(Q3ListBoxItem * item) const |
| bool | itemVisible(int index) |
| bool | itemVisible(const Q3ListBoxItem * item) |
| long | maxItemWidth() const |
| int | numCols() const |
| int | numColumns() const |
| int | numItemsVisible() const |
| int | numRows() const |
| const QPixmap * | pixmap(int index) const |
| void | removeItem(int index) |
| LayoutMode | rowMode() const |
| bool | scrollBar() const |
| Q3ListBoxItem * | selectedItem() const |
| SelectionMode | selectionMode() const |
| void | setAutoBottomScrollBar(bool enable) |
| void | setAutoScroll(bool b) |
| void | setAutoScrollBar(bool enable) |
| void | setAutoUpdate(bool b) |
| virtual void | setBottomItem(int index) |
| void | setBottomScrollBar(bool enable) |
| virtual void | setColumnMode(LayoutMode) |
| virtual void | setColumnMode(int) |
| virtual void | setCurrentItem(int index) |
| virtual void | setCurrentItem(Q3ListBoxItem * i) |
| void | setDragSelect(bool b) |
| void | setFixedVisibleLines(int lines) |
| void | setMultiSelection(bool multi) |
| virtual void | setRowMode(LayoutMode) |
| virtual void | setRowMode(int) |
| void | setScrollBar(bool enable) |
| virtual void | setSelected(Q3ListBoxItem * item, bool select) |
| void | setSelected(int index, bool select) |
| virtual void | setSelectionMode(SelectionMode) |
| void | setSmoothScrolling(bool b) |
| virtual void | setTopItem(int index) |
| virtual void | setVariableHeight(bool) |
| virtual void | setVariableWidth(bool) |
| bool | smoothScrolling() const |
| void | sort(bool ascending = true) |
| void | takeItem(const Q3ListBoxItem * item) |
| QString | text(int index) const |
| int | topItem() const |
| void | triggerUpdate(bool doLayout) |
| bool | variableHeight() const |
| bool | variableWidth() const |
| virtual QVariant | inputMethodQuery(Qt::InputMethodQuery query) const |
| virtual QSize | minimumSizeHint() const |
| virtual QSize | sizeHint() const |
| virtual void | viewportPaintEvent(QPaintEvent * e) |
| void | clear() |
| virtual void | clearSelection() |
| virtual void | ensureCurrentVisible() |
| virtual void | invertSelection() |
| virtual void | selectAll(bool select) |
| void | clicked(Q3ListBoxItem * item) |
| void | clicked(Q3ListBoxItem * item, const QPoint & pnt) |
| void | contextMenuRequested(Q3ListBoxItem * item, const QPoint & pos) |
| void | currentChanged(Q3ListBoxItem * item) |
| void | doubleClicked(Q3ListBoxItem * item) |
| void | highlighted(int index) |
| void | highlighted(Q3ListBoxItem * item) |
| void | highlighted(const QString & text) |
| void | mouseButtonClicked(int button, Q3ListBoxItem * item, const QPoint & pos) |
| void | mouseButtonPressed(int button, Q3ListBoxItem * item, const QPoint & pos) |
| void | onItem(Q3ListBoxItem * i) |
| void | onViewport() |
| void | pressed(Q3ListBoxItem * item) |
| void | pressed(Q3ListBoxItem * item, const QPoint & pnt) |
| void | returnPressed(Q3ListBoxItem * item) |
| void | rightButtonClicked(Q3ListBoxItem * item, const QPoint & point) |
| void | rightButtonPressed(Q3ListBoxItem * item, const QPoint & point) |
| void | selected(int index) |
| void | selected(Q3ListBoxItem * item) |
| void | selected(const QString & text) |
| void | selectionChanged() |
| void | selectionChanged(Q3ListBoxItem * item) |
| void | doLayout() const |
| int | findItem(int yPos) const |
| bool | isRubberSelecting() const |
| virtual void | paintCell(QPainter * p, int row, int col) |
| void | toggleCurrentItem() |
| int | totalHeight() const |
| int | totalWidth() const |
| void | updateCellWidth() |
| void | updateItem(int index) |
| void | updateItem(Q3ListBoxItem * i) |
| virtual void | changeEvent(QEvent * ev) |
| virtual void | contentsContextMenuEvent(QContextMenuEvent * e) |
| virtual bool | eventFilter(QObject * o, QEvent * e) |
| virtual void | focusInEvent(QFocusEvent * e) |
| virtual void | focusOutEvent(QFocusEvent * e) |
| virtual void | keyPressEvent(QKeyEvent * e) |
| virtual void | mouseDoubleClickEvent(QMouseEvent * e) |
| virtual void | mouseMoveEvent(QMouseEvent * e) |
| virtual void | mousePressEvent(QMouseEvent * e) |
| virtual void | mouseReleaseEvent(QMouseEvent * e) |
| virtual void | resizeEvent(QResizeEvent * e) |
| virtual void | showEvent(QShowEvent *) |
TheQ3ListBox 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.
Q3ListBox will add scroll bars as necessary, but it isn't intended forreally 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 becauseQ3ListBox may become slow with huge lists. (SeeQ3ListView andQ3Table for possible alternatives.)
There are a variety of selection modes described in theQ3ListBox::SelectionMode documentation. The default isSingle selection mode, but you can change it usingsetSelectionMode(). (setMultiSelection() is still provided for compatibility with Qt 1.x. We recommend usingsetSelectionMode() in all code.)
BecauseQ3ListBox 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 casesQ3ListBox 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 callingsetVariableHeight(false). The same applies to a column's width, seesetVariableWidth().
TheQ3ListBox's items areQ3ListBoxItem objects.Q3ListBox provides methods to insert new items as strings, as pixmaps, and asQ3ListBoxItem * (insertItem() with various arguments), and to replace an existing item with a new string, pixmap orQ3ListBoxItem (changeItem() with various arguments). You can also remove items singly withremoveItem() orclear() the entire list box. Note that if you create aQ3ListBoxItem yourself and insert it,Q3ListBox takes ownership of the item.
You can also create aQ3ListBoxItem, such asQ3ListBoxText orQ3ListBoxPixmap, 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;Q3ListBox will add scroll bars if necessary.Q3ListBox can display a single-column (the common case) or multiple-columns, and offers both single and multiple selection.Q3ListBox does not support multiple-column items (butQ3ListView andQ3Table do), or tree hierarchies (butQ3ListView does).
The list box items can be accessed both asQ3ListBoxItem objects (recommended) and using integer indexes (the originalQ3ListBox 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 aQ3ListBox contains aQ3ListBoxItem. One of the items can be the current item. ThecurrentChanged() signal and thehighlighted() signal are emitted when a new item becomes current, e.g. because the user clicks on it orQ3ListBox::setCurrentItem() is called. Theselected() 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 andcurrentItem() returns -1.
A list box hasQt::WheelFocus as a defaultfocusPolicy(), i.e. it can get keyboard focus by tabbing, clicking and through the use of the mouse wheel.
New items can be inserted usinginsertItem(),insertStrList() orinsertStringList().
By default, vertical and horizontal scroll bars are added and removed as necessary.setHScrollBarMode() andsetVScrollBarMode() can be used to change this policy.
If you need to insert types other than strings and pixmaps, you must define new classes which inheritQ3ListBoxItem.
Warning: The list box assumes ownership of all list box items and will delete them when it does not need them any more.


See alsoQ3ListView,QComboBox, andQButtonGroup.
This typedef is used inQ3IconView's API for values that are OR'd combinations ofStringComparisonMode values.
See alsoStringComparisonMode.
This enum type is used to specify howQ3ListBox lays out its rows and columns.
| Constant | Value | Description |
|---|---|---|
Q3ListBox::FixedNumber | 0 | There is a fixed number of rows (or columns). |
Q3ListBox::FitToWidth | 1 | There are as many columns as will fit on-screen. |
Q3ListBox::FitToHeight | FitToWidth | There are as many rows as will fit on-screen. |
Q3ListBox::Variable | ? | There are as many rows as are required by the column mode. (Or as many columns as required by the row mode.) |
Example: When you callsetRowMode(FitToHeight),columnMode() automatically becomesVariable to accommodate the row mode you've set.
This enumerated type is used byQ3ListBox to indicate how it reacts to selection by the user.
| Constant | Value | Description |
|---|---|---|
Q3ListBox::Single | 0 | When 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 usingQ3ListBox::clearSelection(). |
Q3ListBox::Multi | 1 | When the user selects an item the selection status of that item is toggled and the other items are left alone. |
Q3ListBox::Extended | 2 | When 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. |
Q3ListBox::NoSelection | 3 | Items 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, andNoSelection is for a list box where the user can look but not touch.
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.
| Constant | Value | Description |
|---|---|---|
Q3ListBox::CaseSensitive | 0x00001 | The strings must match case sensitively. |
Q3ListBox::ExactMatch | 0x00010 | The target and search strings must match exactly. |
Q3ListBox::BeginsWith | 0x00002 | The target string begins with the search string. |
Q3ListBox::EndsWith | 0x00004 | The target string ends with the search string. |
Q3ListBox::Contains | 0x00008 | The target string contains the search string. |
If you OR these flags together (excludingCaseSensitive), the search criteria be applied in the following order:ExactMatch,BeginsWith,EndsWith,Contains.
Matching is case-insensitive unlessCaseSensitive is set.CaseSensitive can be OR-ed with any combination of the other flags.
See alsoComparisonFlags.
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 becomesVariable, unless the column mode isVariable.
Access functions:
| LayoutMode | columnMode() const |
| virtual void | setColumnMode(LayoutMode) |
| virtual void | setColumnMode(int) |
See alsosetRowMode(),rowMode, andnumColumns.
This property holds the number of items in the list box.
Access functions:
| uint | count() const |
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:
| int | currentItem() const |
| virtual void | setCurrentItem(int index) |
| virtual void | setCurrentItem(Q3ListBoxItem * i) |
This property holds the text of the current item.
This is equivalent to text(currentItem()).
Access functions:
| QString | currentText() const |
This property holds whether or not the list box is in Multi selection mode.
Consider using theQ3ListBox::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 orNoSelection mode.
Access functions:
| bool | isMultiSelection() const |
| void | setMultiSelection(bool multi) |
See alsoselectionMode.
This property holds the number of columns in the list box.
This is normally 1, but can be different ifQ3ListBox::columnMode orQ3ListBox::rowMode has been set.
Access functions:
| int | numColumns() const |
See alsocolumnMode,rowMode, andnumRows.
This property holds the number of visible items.
Both partially and entirely visible items are counted.
Access functions:
| int | numItemsVisible() const |
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:
| int | numRows() const |
See alsocolumnMode,rowMode, andnumColumns.
This property holds the row layout mode for this list box.
This property is normallyVariable.
setRowMode() sets the layout mode and adjusts the number of displayed rows. The column layout mode automatically becomesVariable, unless the row mode isVariable.
Access functions:
| LayoutMode | rowMode() const |
| virtual void | setRowMode(LayoutMode) |
| virtual void | setRowMode(int) |
See alsocolumnMode.
This property holds the selection mode of the list box.
Sets the list box's selection mode, which may be one ofSingle (the default),Extended,Multi orNoSelection.
Access functions:
| SelectionMode | selectionMode() const |
| virtual void | setSelectionMode(SelectionMode) |
See alsoSelectionMode.
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 positionindex in the list is displayed in the top row of the list box.
Access functions:
| int | topItem() const |
| virtual void | setTopItem(int index) |
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:
| bool | variableHeight() const |
| virtual void | setVariableHeight(bool) |
See alsovariableWidth.
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:
| bool | variableWidth() const |
| virtual void | setVariableWidth(bool) |
See alsovariableHeight.
Constructs a new empty list box calledname and with parentparent and widget attributesf.
This constructor sets the Qt::WA_StaticContent and theQt::WA_NoBackground attributes to boost performance when drawing Q3ListBoxItems. This may be unsuitable for customQ3ListBoxItem classes, in which caseQt::WA_StaticContents andQt::WA_NoBackground should be cleared on theviewport() after construction.
Destroys the list box. Deletes all list box items.
UsehScrollBarMode() instead. Returns true if the horizontal scrollbar mode is set toAuto.
See alsosetAutoBottomScrollBar().
UsedragAutoScroll() instead. This function always returns true.
See alsosetAutoScroll().
UsevScrollBarMode() instead. Returns true if the vertical scrollbar mode isAuto.
See alsosetAutoScrollBar().
Returns true. Qt always updates automatically.
See alsosetAutoUpdate().
UsehScrollBarMode() instead. Returns true if the horizontal scrollbar mode is notAlwaysOff.
See alsosetBottomScrollBar().
UseitemHeight(i) instead.
UseitemHeight() instead.
UsemaxItemWidth() instead.
UsemaxItemWidth(i) instead.
If there is a current item, the list box is scrolled so that this item is displayed centered.
See alsoQ3ListBox::ensureCurrentVisible().
[virtual protected]void Q3ListBox::changeEvent(QEvent * ev)Reimplemented fromQWidget::changeEvent().
Replaces the item at positionindex withlbi. Ifindex is negative or too large, changeItem() does nothing.
The item that has been changed will become selected.
See alsoinsertItem() andremoveItem().
This is an overloaded function.
Replaces the item at positionindex with a new list box text item with texttext.
The operation is ignored ifindex is out of range.
See alsoinsertItem() andremoveItem().
This is an overloaded function.
Replaces the item at positionindex with a new list box pixmap item with pixmappixmap.
The operation is ignored ifindex is out of range.
See alsoinsertItem() andremoveItem().
This is an overloaded function.
Replaces the item at positionindex with a new list box pixmap item with pixmappixmap and texttext.
The operation is ignored ifindex is out of range.
See alsoinsertItem() andremoveItem().
[slot]void Q3ListBox::clear()Deletes all the items in the list.
See alsoremoveItem().
[virtual slot]void Q3ListBox::clearSelection()Deselects all items, if possible.
Note that aSingle selection list box will automatically select an item if it has keyboard focus.
[signal]void Q3ListBox::clicked(Q3ListBoxItem * item)This signal is emitted when the user clicks any mouse button. Ifitem is not 0, the cursor is onitem. Ifitem is 0, the mouse cursor isn't on any item.
Note that you must not delete anyQ3ListBoxItem objects in slots connected to this signal.
Note:Signalclicked is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3ListBox,static_cast<void(Q3ListBox::*)(Q3ListBoxItem*)>(&Q3ListBox::clicked),[=](Q3ListBoxItem*item){/* ... */ });
[signal]void Q3ListBox::clicked(Q3ListBoxItem * item, constQPoint & pnt)This is an overloaded function.
This signal is emitted when the user clicks any mouse button. Ifitem is not 0, the cursor is onitem. Ifitem 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 anyQ3ListBoxItem objects in slots connected to this signal.
Note:Signalclicked is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3ListBox,static_cast<void(Q3ListBox::*)(Q3ListBoxItem*,constQPoint&)>(&Q3ListBox::clicked),[=](Q3ListBoxItem*item,constQPoint&pnt){/* ... */ });
[virtual protected]void Q3ListBox::contentsContextMenuEvent(QContextMenuEvent * e)Reimplemented fromQ3ScrollView::contentsContextMenuEvent().
[signal]void Q3ListBox::contextMenuRequested(Q3ListBoxItem * item, constQPoint & pos)This signal is emitted when the user invokes a context menu with the right mouse button or with special system keys, withitem 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.
[signal]void Q3ListBox::currentChanged(Q3ListBoxItem * item)This signal is emitted when the user makes a new item the current item.item is the new current list box item.
See alsosetCurrentItem() andcurrentItem().
[protected]void Q3ListBox::doLayout() constThis function does the hard layout work. You should never need to call it.
[signal]void Q3ListBox::doubleClicked(Q3ListBoxItem * item)This signal is emitted whenever an item is double-clicked. It's emitted on the second button press, not the second button release. Ifitem is not 0, the cursor is onitem. Ifitem is 0, the mouse cursor isn't on any item.
Returns true. Dragging always selects.
See alsosetDragSelect().
[virtual slot]void Q3ListBox::ensureCurrentVisible()Ensures that the current item is visible.
[virtual protected]bool Q3ListBox::eventFilter(QObject * o,QEvent * e)Reimplemented fromQObject::eventFilter().
Finds the first list box item that has the texttext and returns it, or returns 0 of no such item could be found. IfComparisonFlags are specified incompare then these flags are used, otherwise the default is a case-insensitive, "begins with" search.
[protected]int Q3ListBox::findItem(int yPos) constUse index(itemAt(yPos)) instead.
Returns the first item in this list box. If the list box is empty, returns 0.
[virtual protected]void Q3ListBox::focusInEvent(QFocusEvent * e)Reimplemented fromQWidget::focusInEvent().
[virtual protected]void Q3ListBox::focusOutEvent(QFocusEvent * e)Reimplemented fromQWidget::focusOutEvent().
[signal]void Q3ListBox::highlighted(int index)This signal is emitted when the user makes a new item the current item.index is the index of the new current item.
Note:Signalhighlighted is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3ListBox,static_cast<void(Q3ListBox::*)(int)>(&Q3ListBox::highlighted),[=](int index){/* ... */ });
See alsocurrentChanged(),selected(),currentItem(), andselectionChanged().
[signal]void Q3ListBox::highlighted(Q3ListBoxItem * item)This is an overloaded function.
This signal is emitted when the user makes a newitem the currentitem.
Note:Signalhighlighted is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3ListBox,static_cast<void(Q3ListBox::*)(Q3ListBoxItem*)>(&Q3ListBox::highlighted),[=](Q3ListBoxItem*item){/* ... */ });
See alsocurrentChanged(),selected(),currentItem(), andselectionChanged().
[signal]void Q3ListBox::highlighted(constQString & text)This is an overloaded 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'stext.
Note:Signalhighlighted is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3ListBox,static_cast<void(Q3ListBox::*)(constQString&)>(&Q3ListBox::highlighted),[=](constQString&text){/* ... */ });
See alsocurrentChanged(),selected(),currentItem(), andselectionChanged().
Using this method is quite inefficient. We suggest to useinsertItem() for inserting andsort() afterwards.
Insertslbi 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 alsoinsertItem() andsort().
This is an overloaded function.
Using this method is quite inefficient. We suggest to useinsertItem() for inserting andsort() afterwards.
Inserts a new item oftext at its sorted position in the list box and returns the position.
All items must be inserted withinSort() to maintain the sorting order.inSort() treats any pixmap (or user-defined type) as lexicographically less than any string.
See alsoinsertItem() andsort().
Returns the index oflbi, or -1 if the item is not in this list box orlbi is 0.
See alsoitem().
[virtual]QVariant Q3ListBox::inputMethodQuery(Qt::InputMethodQuery query) constReimplemented fromQWidget::inputMethodQuery().
Inserts the itemlbi into the list at positionindex.
Ifindex is negative or larger than the number of items in the list box,lbi is inserted at the end of the list.
See alsoinsertStrList().
This is an overloaded function.
Inserts the itemlbi into the list after the itemafter, or at the beginning ifafter is 0.
See alsoinsertStrList().
This is an overloaded function.
Inserts a new list box text item with the texttext into the list at positionindex.
Ifindex is negative,text is inserted at the end of the list.
See alsoinsertStrList().
This is an overloaded function.
Inserts a new list box pixmap item with the pixmappixmap into the list at positionindex.
Ifindex is negative,pixmap is inserted at the end of the list.
See alsoinsertStrList().
This is an overloaded function.
Inserts a new list box pixmap item with the pixmappixmap and the texttext into the list at positionindex.
Ifindex is negative,pixmap is inserted at the end of the list.
See alsoinsertStrList().
Inserts thenumStrings strings of the arraystrings into the list at positionindex.
Ifindex is negative, insertStrList() insertsstrings at the end of the list. Ifindex is too large, the operation is ignored.
Warning: This function usesconst char * rather thanQString, 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. SeeinsertStringList() which uses real QStrings.
Warning: This function is never significantly faster than a loop aroundinsertItem().
See alsoinsertItem() andinsertStringList().
Inserts the string listlist into the list at positionindex.
Ifindex is negative,list is inserted at the end of the list. Ifindex is too large, the operation is ignored.
Warning: This function is never significantly faster than a loop aroundinsertItem().
See alsoinsertItem() andinsertStrList().
[virtual slot]void Q3ListBox::invertSelection()Inverts the selection. Only works inMulti andExtended selection mode.
[protected]bool Q3ListBox::isRubberSelecting() constReturns true if the user is selecting items using a rubber band rectangle; otherwise returns false.
Returns true if itemi is selected; otherwise returns false.
This is an overloaded function.
Returns true if itemi is selected; otherwise returns false.
Returns a pointer to the item at positionindex, or 0 ifindex is out of bounds.
See alsoindex().
Returns the item at pointp, specified in viewport coordinates, or a 0 if there is no item atp.
UsecontentsToViewport() to convert between widget coordinates and viewport coordinates.
Returns the height in pixels of the item with indexindex.index defaults to 0.
Ifindex is too large, this function returns 0.
Returns the rectangle on the screen thatitem occupies inviewport()'s coordinates, or an invalid rectangle ifitem is 0 or is not currently visible.
Returns true if the item at positionindex is at least partly visible; otherwise returns false.
This is an overloaded function.
Returns true ifitem is at least partly visible; otherwise returns false.
[virtual protected]void Q3ListBox::keyPressEvent(QKeyEvent * e)Reimplemented fromQWidget::keyPressEvent().
Returns the width of the widest item in the list box.
[virtual]QSize Q3ListBox::minimumSizeHint() constReimplemented fromQWidget::minimumSizeHint().
[signal]void Q3ListBox::mouseButtonClicked(int button,Q3ListBoxItem * item, constQPoint & pos)This signal is emitted when the user clicks mouse buttonbutton. Ifitem is not 0, the cursor is onitem. Ifitem 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 anyQ3ListBoxItem objects in slots connected to this signal.
[signal]void Q3ListBox::mouseButtonPressed(int button,Q3ListBoxItem * item, constQPoint & pos)This signal is emitted when the user presses mouse buttonbutton. Ifitem is not 0, the cursor is onitem. Ifitem 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 anyQ3ListBoxItem objects in slots connected to this signal.
[virtual protected]void Q3ListBox::mouseDoubleClickEvent(QMouseEvent * e)Reimplemented fromQWidget::mouseDoubleClickEvent().
[virtual protected]void Q3ListBox::mouseMoveEvent(QMouseEvent * e)Reimplemented fromQWidget::mouseMoveEvent().
[virtual protected]void Q3ListBox::mousePressEvent(QMouseEvent * e)Reimplemented fromQWidget::mousePressEvent().
[virtual protected]void Q3ListBox::mouseReleaseEvent(QMouseEvent * e)Reimplemented fromQWidget::mouseReleaseEvent().
UsenumColumns() instead.
[signal]void Q3ListBox::onItem(Q3ListBoxItem * i)This signal is emitted when the user moves the mouse cursor onto an item, similar to theQWidget::enterEvent() function.i is theQ3ListBoxItem that the mouse has moved on.
[signal]void Q3ListBox::onViewport()This signal is emitted when the user moves the mouse cursor from an item to an empty part of the list box.
[virtual protected]void Q3ListBox::paintCell(QPainter * p,int row,int col)Provided for compatibility with the oldQ3ListBox. We recommend usingQ3ListBoxItem::paint() instead.
Repaints the cell atrow,col using painterp.
Returns a pointer to the pixmap at positionindex, or 0 if there is no pixmap there.
See alsotext().
[signal]void Q3ListBox::pressed(Q3ListBoxItem * item)This signal is emitted when the user presses any mouse button. Ifitem is not 0, the cursor is onitem. Ifitem is 0, the mouse cursor isn't on any item.
Note that you must not delete anyQ3ListBoxItem objects in slots connected to this signal.
Note:Signalpressed is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3ListBox,static_cast<void(Q3ListBox::*)(Q3ListBoxItem*)>(&Q3ListBox::pressed),[=](Q3ListBoxItem*item){/* ... */ });
[signal]void Q3ListBox::pressed(Q3ListBoxItem * item, constQPoint & pnt)This is an overloaded function.
This signal is emitted when the user presses any mouse button. Ifitem is not 0, the cursor is onitem. Ifitem 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 anyQ3ListBoxItem objects in slots connected to this signal.
Note:Signalpressed is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3ListBox,static_cast<void(Q3ListBox::*)(Q3ListBoxItem*,constQPoint&)>(&Q3ListBox::pressed),[=](Q3ListBoxItem*item,constQPoint&pnt){/* ... */ });
See alsomouseButtonPressed(),rightButtonPressed(), andclicked().
Removes and deletes the item at positionindex. Ifindex is equal tocurrentItem(), a new item becomes current and thecurrentChanged() andhighlighted() signals are emitted.
See alsoinsertItem() andclear().
[virtual protected]void Q3ListBox::resizeEvent(QResizeEvent * e)Reimplemented fromQWidget::resizeEvent().
[signal]void Q3ListBox::returnPressed(Q3ListBoxItem * item)This signal is emitted when Enter or Return is pressed. Theitem passed in the argument iscurrentItem().
[signal]void Q3ListBox::rightButtonClicked(Q3ListBoxItem * item, constQPoint & point)This signal is emitted when the right button is clicked. Theitem is the item that the button was clicked on (which could be 0 if no item was clicked on), and thepoint is where the click took place in global coordinates.
[signal]void Q3ListBox::rightButtonPressed(Q3ListBoxItem * item, constQPoint & point)This signal is emitted when the right button is pressed. Theitem is the item that the button was pressed over (which could be 0 if no item was pressed over), and thepoint is where the press took place in global coordinates.
UsevScrollBarMode() instead. Returns true if the vertical scrollbar mode is notAlwaysOff.
See alsosetScrollBar().
[virtual slot]void Q3ListBox::selectAll(bool select)InMulti andExtended modes, this function sets all items to be selected ifselect is true, and to be unselected ifselect is false.
InSingle andNoSelection modes, this function only changes the selection status ofcurrentItem().
[signal]void Q3ListBox::selected(int index)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.
Note:Signalselected is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3ListBox,static_cast<void(Q3ListBox::*)(int)>(&Q3ListBox::selected),[=](int index){/* ... */ });
See alsosetSelected(),currentChanged(),highlighted(), andselectionChanged().
[signal]void Q3ListBox::selected(Q3ListBoxItem * item)This is an overloaded function.
This signal is emitted when the user double-clicks on anitem or presses Enter on the currentitem.
Note:Signalselected is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3ListBox,static_cast<void(Q3ListBox::*)(Q3ListBoxItem*)>(&Q3ListBox::selected),[=](Q3ListBoxItem*item){/* ... */ });
See alsocurrentChanged(),highlighted(), andselectionChanged().
[signal]void Q3ListBox::selected(constQString & text)This is an overloaded 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 thetext of the selected item.
Note:Signalselected is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3ListBox,static_cast<void(Q3ListBox::*)(constQString&)>(&Q3ListBox::selected),[=](constQString&text){/* ... */ });
See alsocurrentChanged(),highlighted(), andselectionChanged().
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 alsosetSelected() andsetMultiSelection().
[signal]void Q3ListBox::selectionChanged()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,Q3ListBox tries to emit just one selectionChanged() signal so the signal can be connected to computationally expensive slots.
Note:SignalselectionChanged is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3ListBox,static_cast<void(Q3ListBox::*)()>(&Q3ListBox::selectionChanged),[=](){/* ... */ });
See alsoselected() andcurrentItem().
[signal]void Q3ListBox::selectionChanged(Q3ListBoxItem * item)This is an overloaded function.
This signal is emitted when the selection in aSingle selection list box changes.item is the newly selected list box item.
Note:SignalselectionChanged is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(3ListBox,static_cast<void(Q3ListBox::*)(Q3ListBoxItem*)>(&Q3ListBox::selectionChanged),[=](Q3ListBoxItem*item){/* ... */ });
See alsoselected() andcurrentItem().
UsesetHScrollBarMode() instead.
Ifenable is true, passAuto as the argument tosetHScrollBarMode(); otherwise, passAlwaysOff.
See alsoautoBottomScrollBar().
UsesetDragAutoScroll(b) instead.
See alsoautoScroll().
UsesetVScrollBarMode() instead.
Ifenable is true, passAuto as the argument tosetVScrollBarMode(); otherwise, passAlwaysOff.
See alsoautoScrollBar().
Does nothing. Qt always updates automatically. Theb parameter is ignored.
See alsoautoUpdate().
[virtual]void Q3ListBox::setBottomItem(int index)Scrolls the list box so the item at positionindex in the list is displayed in the bottom row of the list box.
See alsosetTopItem().
UsesetHScrollBarMode() instead.
Ifenable is true, passAlwaysOn as the argument tosetHScrollBarMode(); otherwise, passAlwaysOff.
See alsobottomScrollBar().
Does nothing. Dragging always selects. Theb parameter is ignored.
See alsodragSelect().
UsesetRowMode(lines) instead.
UsesetVScrollBarMode() instead.
Ifenable is true, passAlwaysOn as the argument tosetVScrollBarMode(); otherwise, passAlwaysOff.
See alsoscrollBar().
[virtual]void Q3ListBox::setSelected(Q3ListBoxItem * item,bool select)Selectsitem ifselect is true or unselects it ifselect is false, and repaints the item appropriately.
If the list box is aSingle selection list box andselect is true, setSelected() callssetCurrentItem().
If the list box is aSingle selection list box,select is false, setSelected() callsclearSelection().
See alsoselected(),setMultiSelection(),setCurrentItem(),clearSelection(), andcurrentItem().
This is an overloaded function.
Ifselect is true the item at positionindex is selected; otherwise the item is deselected.
Does nothing. Qt always scrolls smoothly. Theb parameter is ignored.
See alsosmoothScrolling().
[virtual protected]void Q3ListBox::showEvent(QShowEvent *)Reimplemented fromQWidget::showEvent().
[virtual]QSize Q3ListBox::sizeHint() constReimplemented fromQWidget::sizeHint().
Returns false. Qt always scrolls smoothly.
See alsosetSmoothScrolling().
Ifascending is true sorts the items in ascending order; otherwise sorts in descending order.
To compare the items, the text (Q3ListBoxItem::text()) of the items is used.
Removesitem 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 Q3ListBoxItem::~Q3ListBoxItem() calls it. The normal way to delete an item is withdelete.
See alsoQ3ListBox::insertItem().
Returns the text at positionindex, or an empty string if there is no text at that position.
See alsopixmap().
[protected]void Q3ListBox::toggleCurrentItem()Toggles the selection status ofcurrentItem() and repaints if the list box is aMulti selection list box.
See alsosetMultiSelection().
[protected]int Q3ListBox::totalHeight() constUsecontentsHeight() instead.
[protected]int Q3ListBox::totalWidth() constUsecontentsWidth() instead.
Ensures that a single paint event will occur at the end of the current event loop iteration. IfdoLayout is true, the layout is also redone.
[protected]void Q3ListBox::updateCellWidth()Does nothing. Qt automatically updates.
[protected]void Q3ListBox::updateItem(int index)Repaints the item at positionindex in the list.
[protected]void Q3ListBox::updateItem(Q3ListBoxItem * i)This is an overloaded function.
Repaints theQ3ListBoxItemi.
[virtual]void Q3ListBox::viewportPaintEvent(QPaintEvent * e)Reimplemented fromQ3ScrollView::viewportPaintEvent().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.