The Q3ListBox widget provides a list of selectable, read-only items. 更多...
| 头: | #include <Q3ListBox> |
| 继承: | 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 *) |
The Q3ListBox 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 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 Q3ListBox may become slow with huge lists. (See Q3ListView and Q3Table for possible alternatives.)
There are a variety of selection modes described in the Q3ListBox::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.)
因为 Q3ListBox 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 Q3ListBox 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 Q3ListBox 's items are Q3ListBoxItem 对象。 Q3ListBox provides methods to insert new items as strings, as pixmaps, and as Q3ListBoxItem * ( insertItem () with various arguments), and to replace an existing item with a new string, pixmap or Q3ListBoxItem ( changeItem () with various arguments). You can also remove items singly with removeItem () 或 clear () the entire list box. Note that if you create a Q3ListBoxItem yourself and insert it, Q3ListBox takes ownership of the item.
You can also create a Q3ListBoxItem ,譬如 Q3ListBoxText or Q3ListBoxPixmap , 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 (but Q3ListView and Q3Table do), or tree hierarchies (but Q3ListView does).
The list box items can be accessed both as Q3ListBoxItem objects (recommended) and using integer indexes (the original Q3ListBox 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 Q3ListBox 包含 Q3ListBoxItem . 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 Q3ListBox::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 () 或 insertStringList ().
By default, vertical and horizontal scroll bars are added and removed as necessary. setHScrollBarMode () 和 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 Q3ListBoxItem .
警告: The list box assumes ownership of all list box items and will delete them when it does not need them any more.
另请参阅 Q3ListView , QComboBox ,和 QButtonGroup .
This typedef is used in Q3IconView 's API for values that are OR'd combinations of StringComparisonMode 值。
另请参阅 StringComparisonMode .
This enum type is used to specify how Q3ListBox lays out its rows and columns.
| 常量 | 值 | 描述 |
|---|---|---|
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 call
setRowMode
(FitToHeight),
columnMode
() automatically becomes
变量
to accommodate the row mode you've set.
This enumerated type is used by Q3ListBox to indicate how it reacts to selection by the user.
| 常量 | 值 | 描述 |
|---|---|---|
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 using Q3ListBox::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
|
无法选择项。 |
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.
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.
| 常量 | 值 | 描述 |
|---|---|---|
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 (excluding
CaseSensitive
), the search criteria be applied in the following order:
ExactMatch
,
BeginsWith
,
EndsWith
,
Contains
.
Matching is case-insensitive unless
CaseSensitive
有设置。
CaseSensitive
can be OR-ed with any combination of the other flags.
另请参阅 ComparisonFlags .
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
变量
, unless the column mode is
变量
.
访问函数:
| LayoutMode | columnMode () const |
| virtual void | setColumnMode (LayoutMode) |
| virtual void | setColumnMode (int) |
另请参阅 setRowMode (), rowMode ,和 numColumns .
This property holds the number of items in the list box.
访问函数:
| 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.
访问函数:
| 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 ()).
访问函数:
| QString | currentText () const |
This property holds whether or not the list box is in Multi selection mode.
Consider using the Q3ListBox::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 模式。
访问函数:
| bool | isMultiSelection () const |
| void | setMultiSelection (bool multi ) |
另请参阅 selectionMode .
This property holds the number of columns in the list box.
This is normally 1, but can be different if Q3ListBox::columnMode or Q3ListBox::rowMode has been set.
访问函数:
| int | numColumns () const |
另请参阅 columnMode , rowMode ,和 numRows .
This property holds the number of visible items.
Both partially and entirely visible items are counted.
访问函数:
| 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.
访问函数:
| int | numRows () const |
另请参阅 columnMode , rowMode ,和 numColumns .
This property holds the row layout mode for this list box.
This property is normally
变量
.
setRowMode() sets the layout mode and adjusts the number of displayed rows. The column layout mode automatically becomes
变量
, unless the row mode is
变量
.
访问函数:
| LayoutMode | rowMode () const |
| virtual void | setRowMode (LayoutMode) |
| virtual void | setRowMode (int) |
另请参阅 columnMode .
This property holds the selection mode of the list box.
Sets the list box's selection mode, which may be one of
Single
(默认),
Extended
,
Multi
or
NoSelection
.
访问函数:
| SelectionMode | selectionMode () const |
| virtual void | setSelectionMode (SelectionMode) |
另请参阅 SelectionMode .
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.
访问函数:
| 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.
访问函数:
| bool | variableHeight () const |
| virtual void | setVariableHeight (bool) |
另请参阅 variableWidth .
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.
访问函数:
| bool | variableWidth () const |
| virtual void | setVariableWidth (bool) |
另请参阅 variableHeight .
Constructs a new empty list box called name and with parent parent and widget attributes f .
This constructor sets the Qt::WA_StaticContent and the Qt::WA_NoBackground attributes to boost performance when drawing Q3ListBoxItems. This may be unsuitable for custom Q3ListBoxItem classes, in which case Qt::WA_StaticContents and Qt::WA_NoBackground should be cleared on the viewport () after construction.
Destroys the list box. Deletes all list box items.
使用
hScrollBarMode
() instead. Returns true if the horizontal scrollbar mode is set to
Auto
.
另请参阅 setAutoBottomScrollBar ().
使用 dragAutoScroll () instead. This function always returns true.
另请参阅 setAutoScroll ().
使用
vScrollBarMode
() instead. Returns true if the vertical scrollbar mode is
Auto
.
另请参阅 setAutoScrollBar ().
Returns true. Qt always updates automatically.
另请参阅 setAutoUpdate ().
使用
hScrollBarMode
() instead. Returns true if the horizontal scrollbar mode is not
AlwaysOff
.
另请参阅 setBottomScrollBar ().
使用 itemHeight ( i ) 代替。
使用 itemHeight () 代替。
使用 maxItemWidth () 代替。
使用 maxItemWidth ( i ) 代替。
If there is a current item, the list box is scrolled so that this item is displayed centered.
另请参阅 Q3ListBox::ensureCurrentVisible ().
[virtual protected]
void
Q3ListBox::
changeEvent
(
QEvent
*
ev
)
重实现自 QWidget::changeEvent ().
Replaces the item at position index with lbi 。若 index is negative or too large, changeItem() does nothing.
The item that has been changed will become selected.
另请参阅 insertItem () 和 removeItem ().
这是重载函数。
Replaces the item at position index with a new list box text item with text text .
The operation is ignored if index 超出范围。
另请参阅 insertItem () 和 removeItem ().
这是重载函数。
Replaces the item at position index with a new list box pixmap item with pixmap pixmap .
The operation is ignored if index 超出范围。
另请参阅 insertItem () 和 removeItem ().
这是重载函数。
Replaces the item at position index with a new list box pixmap item with pixmap pixmap 和文本 text .
The operation is ignored if index 超出范围。
另请参阅 insertItem () 和 removeItem ().
[slot]
void
Q3ListBox::
clear
()
Deletes all the items in the list.
另请参阅 removeItem ().
[virtual slot]
void
Q3ListBox::
clearSelection
()
Deselects all items, if possible.
注意,
Single
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. If item is not 0, the cursor is on item 。若 item is 0, the mouse cursor isn't on any item.
Note that you must not delete any Q3ListBoxItem objects in slots connected to this signal.
注意: 信号 clicked 在此类中是重载。要使用函数指针句法连接到此信号,必须在静态铸造中指定信号类型,如此范例所示:
connect(3ListBox, static_cast<void(Q3ListBox::*)(Q3ListBoxItem *)>(&Q3ListBox::clicked), [=](Q3ListBoxItem *item){ /* ... */ });
[signal]
void
Q3ListBox::
clicked
(
Q3ListBoxItem
*
item
, const
QPoint
&
pnt
)
这是重载函数。
This signal is emitted when the user clicks any mouse button. If item is not 0, the cursor is on item 。若 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 Q3ListBoxItem objects in slots connected to this signal.
注意: 信号 clicked 在此类中是重载。要使用函数指针句法连接到此信号,必须在静态铸造中指定信号类型,如此范例所示:
connect(3ListBox, static_cast<void(Q3ListBox::*)(Q3ListBoxItem *, const QPoint &)>(&Q3ListBox::clicked), [=](Q3ListBoxItem *item, const QPoint &pnt){ /* ... */ });
[virtual protected]
void
Q3ListBox::
contentsContextMenuEvent
(
QContextMenuEvent
*
e
)
重实现自 Q3ScrollView::contentsContextMenuEvent ().
[signal]
void
Q3ListBox::
contextMenuRequested
(
Q3ListBoxItem
*
item
, const
QPoint
&
pos
)
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.
[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.
另请参阅 setCurrentItem () 和 currentItem ().
[protected]
void
Q3ListBox::
doLayout
() const
This 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. If item is not 0, the cursor is on item 。若 item is 0, the mouse cursor isn't on any item.
Returns true. Dragging always selects.
另请参阅 setDragSelect ().
[virtual slot]
void
Q3ListBox::
ensureCurrentVisible
()
Ensures that the current item is visible.
[virtual protected]
bool
Q3ListBox::
eventFilter
(
QObject
*
o
,
QEvent
*
e
)
重实现自 QObject::eventFilter ().
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.
[protected]
int
Q3ListBox::
findItem
(
int
yPos
) const
Use 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
)
重实现自 QWidget::focusInEvent ().
[virtual protected]
void
Q3ListBox::
focusOutEvent
(
QFocusEvent
*
e
)
重实现自 QWidget::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.
注意: 信号 highlighted 在此类中是重载。要使用函数指针句法连接到此信号,必须在静态铸造中指定信号类型,如此范例所示:
connect(3ListBox, static_cast<void(Q3ListBox::*)(int)>(&Q3ListBox::highlighted), [=](int index){ /* ... */ });
另请参阅 currentChanged (), selected (), currentItem (),和 selectionChanged ().
[signal]
void
Q3ListBox::
highlighted
(
Q3ListBoxItem
*
item
)
这是重载函数。
This signal is emitted when the user makes a new item the current item .
注意: 信号 highlighted 在此类中是重载。要使用函数指针句法连接到此信号,必须在静态铸造中指定信号类型,如此范例所示:
connect(3ListBox, static_cast<void(Q3ListBox::*)(Q3ListBoxItem *)>(&Q3ListBox::highlighted), [=](Q3ListBoxItem *item){ /* ... */ });
另请参阅 currentChanged (), selected (), currentItem (),和 selectionChanged ().
[signal]
void
Q3ListBox::
highlighted
(const
QString
&
text
)
这是重载函数。
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 .
注意: 信号 highlighted 在此类中是重载。要使用函数指针句法连接到此信号,必须在静态铸造中指定信号类型,如此范例所示:
connect(3ListBox, static_cast<void(Q3ListBox::*)(const QString &)>(&Q3ListBox::highlighted), [=](const QString &text){ /* ... */ });
另请参阅 currentChanged (), selected (), currentItem (),和 selectionChanged ().
Using this method is quite inefficient. We suggest to use insertItem () for inserting and sort () afterwards.
插入 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.
另请参阅 insertItem () 和 sort ().
这是重载函数。
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.
另请参阅 insertItem () 和 sort ().
返回索引对于 lbi , or -1 if the item is not in this list box or lbi 为 0。
另请参阅 item ().
[虚拟]
QVariant
Q3ListBox::
inputMethodQuery
(
Qt::InputMethodQuery
query
) const
重实现自 QWidget::inputMethodQuery ().
Inserts the item lbi into the list at position index .
若 index is negative or larger than the number of items in the list box, lbi is inserted at the end of the list.
另请参阅 insertStrList ().
这是重载函数。
Inserts the item lbi into the list after the item after , or at the beginning if after 为 0。
另请参阅 insertStrList ().
这是重载函数。
Inserts a new list box text item with the text text into the list at position index .
若 index 为负, text is inserted at the end of the list.
另请参阅 insertStrList ().
这是重载函数。
Inserts a new list box pixmap item with the pixmap pixmap into the list at position index .
若 index 为负, pixmap is inserted at the end of the list.
另请参阅 insertStrList ().
这是重载函数。
Inserts a new list box pixmap item with the pixmap pixmap 和文本 text into the list at position index .
若 index 为负, pixmap is inserted at the end of the list.
另请参阅 insertStrList ().
插入 numStrings strings of the array strings into the list at position index .
若 index is negative, insertStrList() inserts strings at the end of the list. If index is too large, the operation is ignored.
警告:
此函数使用
const char *
而不是
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.
警告: This function is never significantly faster than a loop around insertItem ().
另请参阅 insertItem () 和 insertStringList ().
Inserts the string list list into the list at position index .
若 index 为负, list is inserted at the end of the list. If index is too large, the operation is ignored.
警告: This function is never significantly faster than a loop around insertItem ().
另请参阅 insertItem () 和 insertStrList ().
[virtual slot]
void
Q3ListBox::
invertSelection
()
Inverts the selection. Only works in
Multi
and
Extended
selection mode.
[protected]
bool
Q3ListBox::
isRubberSelecting
() const
Returns true if the user is selecting items using a rubber band rectangle; otherwise returns false.
Returns true if item i is selected; otherwise returns false.
这是重载函数。
Returns true if item i is selected; otherwise returns false.
Returns a pointer to the item at position index , or 0 if index is out of bounds.
另请参阅 index ().
Returns the item at point p , specified in viewport coordinates, or a 0 if there is no item at p .
使用 contentsToViewport () to convert between widget coordinates and viewport coordinates.
Returns the height in pixels of the item with index index . index defaults to 0.
若 index is too large, this function returns 0.
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.
Returns true if the item at position index is at least partly visible; otherwise returns false.
这是重载函数。
返回 true 若 item is at least partly visible; otherwise returns false.
[virtual protected]
void
Q3ListBox::
keyPressEvent
(
QKeyEvent
*
e
)
重实现自 QWidget::keyPressEvent ().
Returns the width of the widest item in the list box.
[虚拟]
QSize
Q3ListBox::
minimumSizeHint
() const
重实现自 QWidget::minimumSizeHint ().
[signal]
void
Q3ListBox::
mouseButtonClicked
(
int
button
,
Q3ListBoxItem
*
item
, const
QPoint
&
pos
)
This signal is emitted when the user clicks mouse button button 。若 item is not 0, the cursor is on item 。若 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 Q3ListBoxItem objects in slots connected to this signal.
[signal]
void
Q3ListBox::
mouseButtonPressed
(
int
button
,
Q3ListBoxItem
*
item
, const
QPoint
&
pos
)
This signal is emitted when the user presses mouse button button 。若 item is not 0, the cursor is on item 。若 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 Q3ListBoxItem objects in slots connected to this signal.
[virtual protected]
void
Q3ListBox::
mouseDoubleClickEvent
(
QMouseEvent
*
e
)
重实现自 QWidget::mouseDoubleClickEvent ().
[virtual protected]
void
Q3ListBox::
mouseMoveEvent
(
QMouseEvent
*
e
)
重实现自 QWidget::mouseMoveEvent ().
[virtual protected]
void
Q3ListBox::
mousePressEvent
(
QMouseEvent
*
e
)
重实现自 QWidget::mousePressEvent ().
[virtual protected]
void
Q3ListBox::
mouseReleaseEvent
(
QMouseEvent
*
e
)
重实现自 QWidget::mouseReleaseEvent ().
使用 numColumns () 代替。
[signal]
void
Q3ListBox::
onItem
(
Q3ListBoxItem
*
i
)
This signal is emitted when the user moves the mouse cursor onto an item, similar to the QWidget::enterEvent () 函数。 i 是 Q3ListBoxItem 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 old Q3ListBox . We recommend using Q3ListBoxItem::paint () 代替。
Repaints the cell at row , col using painter p .
Returns a pointer to the pixmap at position index , or 0 if there is no pixmap there.
另请参阅 text ().
[signal]
void
Q3ListBox::
pressed
(
Q3ListBoxItem
*
item
)
This signal is emitted when the user presses any mouse button. If item is not 0, the cursor is on item 。若 item is 0, the mouse cursor isn't on any item.
Note that you must not delete any Q3ListBoxItem objects in slots connected to this signal.
注意: 信号 pressed 在此类中是重载。要使用函数指针句法连接到此信号,必须在静态铸造中指定信号类型,如此范例所示:
connect(3ListBox, static_cast<void(Q3ListBox::*)(Q3ListBoxItem *)>(&Q3ListBox::pressed), [=](Q3ListBoxItem *item){ /* ... */ });
[signal]
void
Q3ListBox::
pressed
(
Q3ListBoxItem
*
item
, const
QPoint
&
pnt
)
这是重载函数。
This signal is emitted when the user presses any mouse button. If item is not 0, the cursor is on item 。若 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 Q3ListBoxItem objects in slots connected to this signal.
注意: 信号 pressed 在此类中是重载。要使用函数指针句法连接到此信号,必须在静态铸造中指定信号类型,如此范例所示:
connect(3ListBox, static_cast<void(Q3ListBox::*)(Q3ListBoxItem *, const QPoint &)>(&Q3ListBox::pressed), [=](Q3ListBoxItem *item, const QPoint &pnt){ /* ... */ });
另请参阅 mouseButtonPressed (), rightButtonPressed (),和 clicked ().
Removes and deletes the item at position index 。若 index 等于 currentItem (), a new item becomes current and the currentChanged () 和 highlighted () signals are emitted.
另请参阅 insertItem () 和 clear ().
[virtual protected]
void
Q3ListBox::
resizeEvent
(
QResizeEvent
*
e
)
重实现自 QWidget::resizeEvent ().
[signal]
void
Q3ListBox::
returnPressed
(
Q3ListBoxItem
*
item
)
This signal is emitted when Enter or Return is pressed. The item passed in the argument is currentItem ().
[signal]
void
Q3ListBox::
rightButtonClicked
(
Q3ListBoxItem
*
item
, const
QPoint
&
point
)
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.
[signal]
void
Q3ListBox::
rightButtonPressed
(
Q3ListBoxItem
*
item
, const
QPoint
&
point
)
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.
使用
vScrollBarMode
() instead. Returns true if the vertical scrollbar mode is not
AlwaysOff
.
另请参阅 setScrollBar ().
[virtual slot]
void
Q3ListBox::
selectAll
(
bool
select
)
在
Multi
and
Extended
modes, this function sets all items to be selected if
select
is true, and to be unselected if
select
为 false。
在
Single
and
NoSelection
modes, this function only changes the selection status of
currentItem
().
[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.
注意: 信号 selected 在此类中是重载。要使用函数指针句法连接到此信号,必须在静态铸造中指定信号类型,如此范例所示:
connect(3ListBox, static_cast<void(Q3ListBox::*)(int)>(&Q3ListBox::selected), [=](int index){ /* ... */ });
另请参阅 setSelected (), currentChanged (), highlighted (),和 selectionChanged ().
[signal]
void
Q3ListBox::
selected
(
Q3ListBoxItem
*
item
)
这是重载函数。
This signal is emitted when the user double-clicks on an item or presses Enter on the current item .
注意: 信号 selected 在此类中是重载。要使用函数指针句法连接到此信号,必须在静态铸造中指定信号类型,如此范例所示:
connect(3ListBox, static_cast<void(Q3ListBox::*)(Q3ListBoxItem *)>(&Q3ListBox::selected), [=](Q3ListBoxItem *item){ /* ... */ });
另请参阅 currentChanged (), highlighted (),和 selectionChanged ().
[signal]
void
Q3ListBox::
selected
(const
QString
&
text
)
这是重载函数。
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.
注意: 信号 selected 在此类中是重载。要使用函数指针句法连接到此信号,必须在静态铸造中指定信号类型,如此范例所示:
connect(3ListBox, static_cast<void(Q3ListBox::*)(const QString &)>(&Q3ListBox::selected), [=](const QString &text){ /* ... */ });
另请参阅 currentChanged (), highlighted (),和 selectionChanged ().
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.
另请参阅 setSelected () 和 setMultiSelection ().
[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.
注意: 信号 selectionChanged 在此类中是重载。要使用函数指针句法连接到此信号,必须在静态铸造中指定信号类型,如此范例所示:
connect(3ListBox, static_cast<void(Q3ListBox::*)()>(&Q3ListBox::selectionChanged), [=](){ /* ... */ });
另请参阅 selected () 和 currentItem ().
[signal]
void
Q3ListBox::
selectionChanged
(
Q3ListBoxItem
*
item
)
这是重载函数。
This signal is emitted when the selection in a Single selection list box changes. item is the newly selected list box item.
注意: 信号 selectionChanged 在此类中是重载。要使用函数指针句法连接到此信号,必须在静态铸造中指定信号类型,如此范例所示:
connect(3ListBox, static_cast<void(Q3ListBox::*)(Q3ListBoxItem *)>(&Q3ListBox::selectionChanged), [=](Q3ListBoxItem *item){ /* ... */ });
另请参阅 selected () 和 currentItem ().
使用 setHScrollBarMode () 代替。
若
enable
is true, pass
Auto
as the argument to
setHScrollBarMode
(); otherwise, pass
AlwaysOff
.
另请参阅 autoBottomScrollBar ().
使用 setDragAutoScroll ( b ) 代替。
另请参阅 autoScroll ().
使用 setVScrollBarMode () 代替。
若
enable
is true, pass
Auto
as the argument to
setVScrollBarMode
(); otherwise, pass
AlwaysOff
.
另请参阅 autoScrollBar ().
Does nothing. Qt always updates automatically. The b 参数被忽略。
另请参阅 autoUpdate ().
[虚拟]
void
Q3ListBox::
setBottomItem
(
int
index
)
Scrolls the list box so the item at position index in the list is displayed in the bottom row of the list box.
另请参阅 setTopItem ().
使用 setHScrollBarMode () 代替。
若
enable
is true, pass
AlwaysOn
as the argument to
setHScrollBarMode
(); otherwise, pass
AlwaysOff
.
另请参阅 bottomScrollBar ().
Does nothing. Dragging always selects. The b 参数被忽略。
另请参阅 dragSelect ().
使用 setRowMode ( lines ) 代替。
使用 setVScrollBarMode () 代替。
若
enable
is true, pass
AlwaysOn
as the argument to
setVScrollBarMode
(); otherwise, pass
AlwaysOff
.
另请参阅 scrollBar ().
[虚拟]
void
Q3ListBox::
setSelected
(
Q3ListBoxItem
*
item
,
bool
select
)
选择 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
().
另请参阅 selected (), setMultiSelection (), setCurrentItem (), clearSelection (),和 currentItem ().
这是重载函数。
若 select is true the item at position index is selected; otherwise the item is deselected.
Does nothing. Qt always scrolls smoothly. The b 参数被忽略。
另请参阅 smoothScrolling ().
[virtual protected]
void
Q3ListBox::
showEvent
(
QShowEvent
*)
重实现自 QWidget::showEvent ().
[虚拟]
QSize
Q3ListBox::
sizeHint
() const
重实现自 QWidget::sizeHint ().
Returns false. Qt always scrolls smoothly.
另请参阅 setSmoothScrolling ().
若 ascending 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.
移除
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 Q3ListBoxItem::~Q3ListBoxItem() calls it. The normal way to delete an item is with
delete
.
另请参阅 Q3ListBox::insertItem ().
Returns the text at position index , or an empty string if there is no text at that position.
另请参阅 pixmap ().
[protected]
void
Q3ListBox::
toggleCurrentItem
()
Toggles the selection status of
currentItem
() and repaints if the list box is a
Multi
selection list box.
另请参阅 setMultiSelection ().
[protected]
int
Q3ListBox::
totalHeight
() const
使用 contentsHeight () 代替。
[protected]
int
Q3ListBox::
totalWidth
() const
使用 contentsWidth () 代替。
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.
[protected]
void
Q3ListBox::
updateCellWidth
()
Does nothing. Qt automatically updates.
[protected]
void
Q3ListBox::
updateItem
(
int
index
)
Repaints the item at position index 在列表中。
[protected]
void
Q3ListBox::
updateItem
(
Q3ListBoxItem
*
i
)
这是重载函数。
Repaints the Q3ListBoxItem i .
[虚拟]
void
Q3ListBox::
viewportPaintEvent
(
QPaintEvent
*
e
)
重实现自 Q3ScrollView::viewportPaintEvent ().