Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

  • Qt 4.8
  • Qt3SupportLight
  • Q3ListBox

Q3ListBox Class

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

Header:#include <Q3ListBox>
Inherits:Q3ScrollView

Public Types

typedefComparisonFlags
enumLayoutMode { FixedNumber, FitToWidth, FitToHeight, Variable }
enumSelectionMode { Single, Multi, Extended, NoSelection }
enumStringComparisonMode { CaseSensitive, ExactMatch, BeginsWith, EndsWith, Contains }

Properties

Public Functions

Q3ListBox(QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0)
~Q3ListBox()
boolautoBottomScrollBar() const
boolautoScroll() const
boolautoScrollBar() const
boolautoUpdate() const
boolbottomScrollBar() const
intcellHeight(int i) const
intcellHeight() const
intcellWidth() const
intcellWidth(int i) const
voidcenterCurrentItem()
voidchangeItem(const Q3ListBoxItem * lbi, int index)
voidchangeItem(const QString & text, int index)
voidchangeItem(const QPixmap & pixmap, int index)
voidchangeItem(const QPixmap & pixmap, const QString & text, int index)
LayoutModecolumnMode() const
uintcount() const
intcurrentItem() const
QStringcurrentText() const
booldragSelect() const
Q3ListBoxItem *findItem(const QString & text, ComparisonFlags compare = BeginsWith) const
Q3ListBoxItem *firstItem() const
intinSort(const Q3ListBoxItem * lbi)
intinSort(const QString & text)
intindex(const Q3ListBoxItem * lbi) const
voidinsertItem(const Q3ListBoxItem * lbi, int index = -1)
voidinsertItem(const Q3ListBoxItem * lbi, const Q3ListBoxItem * after)
voidinsertItem(const QString & text, int index = -1)
voidinsertItem(const QPixmap & pixmap, int index = -1)
voidinsertItem(const QPixmap & pixmap, const QString & text, int index = -1)
voidinsertStrList(const char ** strings, int numStrings = -1, int index = -1)
voidinsertStringList(const QStringList & list, int index = -1)
boolisMultiSelection() const
boolisSelected(int i) const
boolisSelected(const Q3ListBoxItem * i) const
Q3ListBoxItem *item(int index) const
Q3ListBoxItem *itemAt(const QPoint & p) const
intitemHeight(int index = 0) const
QRectitemRect(Q3ListBoxItem * item) const
boolitemVisible(int index)
boolitemVisible(const Q3ListBoxItem * item)
longmaxItemWidth() const
intnumCols() const
intnumColumns() const
intnumItemsVisible() const
intnumRows() const
const QPixmap *pixmap(int index) const
voidremoveItem(int index)
LayoutModerowMode() const
boolscrollBar() const
Q3ListBoxItem *selectedItem() const
SelectionModeselectionMode() const
voidsetAutoBottomScrollBar(bool enable)
voidsetAutoScroll(bool b)
voidsetAutoScrollBar(bool enable)
voidsetAutoUpdate(bool b)
virtual voidsetBottomItem(int index)
voidsetBottomScrollBar(bool enable)
virtual voidsetColumnMode(LayoutMode)
virtual voidsetColumnMode(int)
virtual voidsetCurrentItem(int index)
virtual voidsetCurrentItem(Q3ListBoxItem * i)
voidsetDragSelect(bool b)
voidsetFixedVisibleLines(int lines)
voidsetMultiSelection(bool multi)
virtual voidsetRowMode(LayoutMode)
virtual voidsetRowMode(int)
voidsetScrollBar(bool enable)
virtual voidsetSelected(Q3ListBoxItem * item, bool select)
voidsetSelected(int index, bool select)
virtual voidsetSelectionMode(SelectionMode)
voidsetSmoothScrolling(bool b)
virtual voidsetTopItem(int index)
virtual voidsetVariableHeight(bool)
virtual voidsetVariableWidth(bool)
boolsmoothScrolling() const
voidsort(bool ascending = true)
voidtakeItem(const Q3ListBoxItem * item)
QStringtext(int index) const
inttopItem() const
voidtriggerUpdate(bool doLayout)
boolvariableHeight() const
boolvariableWidth() const

Reimplemented Public Functions

virtual QVariantinputMethodQuery(Qt::InputMethodQuery query) const
virtual QSizeminimumSizeHint() const
virtual QSizesizeHint() const
virtual voidviewportPaintEvent(QPaintEvent * e)
  • 49 public functions inherited fromQ3ScrollView
  • 4 public functions inherited fromQ3Frame
  • 14 public functions inherited fromQFrame
  • 220 public functions inherited fromQWidget
  • 29 public functions inherited fromQObject
  • 12 public functions inherited fromQPaintDevice

Public Slots

voidclear()
virtual voidclearSelection()
virtual voidensureCurrentVisible()
virtual voidinvertSelection()
virtual voidselectAll(bool select)

Signals

voidclicked(Q3ListBoxItem * item)
voidclicked(Q3ListBoxItem * item, const QPoint & pnt)
voidcontextMenuRequested(Q3ListBoxItem * item, const QPoint & pos)
voidcurrentChanged(Q3ListBoxItem * item)
voiddoubleClicked(Q3ListBoxItem * item)
voidhighlighted(int index)
voidhighlighted(Q3ListBoxItem * item)
voidhighlighted(const QString & text)
voidmouseButtonClicked(int button, Q3ListBoxItem * item, const QPoint & pos)
voidmouseButtonPressed(int button, Q3ListBoxItem * item, const QPoint & pos)
voidonItem(Q3ListBoxItem * i)
voidonViewport()
voidpressed(Q3ListBoxItem * item)
voidpressed(Q3ListBoxItem * item, const QPoint & pnt)
voidreturnPressed(Q3ListBoxItem * item)
voidrightButtonClicked(Q3ListBoxItem * item, const QPoint & point)
voidrightButtonPressed(Q3ListBoxItem * item, const QPoint & point)
voidselected(int index)
voidselected(Q3ListBoxItem * item)
voidselected(const QString & text)
voidselectionChanged()
voidselectionChanged(Q3ListBoxItem * item)

Protected Functions

voiddoLayout() const
intfindItem(int yPos) const
boolisRubberSelecting() const
virtual voidpaintCell(QPainter * p, int row, int col)
voidtoggleCurrentItem()
inttotalHeight() const
inttotalWidth() const
voidupdateCellWidth()
voidupdateItem(int index)
voidupdateItem(Q3ListBoxItem * i)

Reimplemented Protected Functions

virtual voidchangeEvent(QEvent * ev)
virtual voidcontentsContextMenuEvent(QContextMenuEvent * e)
virtual booleventFilter(QObject * o, QEvent * e)
virtual voidfocusInEvent(QFocusEvent * e)
virtual voidfocusOutEvent(QFocusEvent * e)
virtual voidkeyPressEvent(QKeyEvent * e)
virtual voidmouseDoubleClickEvent(QMouseEvent * e)
virtual voidmouseMoveEvent(QMouseEvent * e)
virtual voidmousePressEvent(QMouseEvent * e)
virtual voidmouseReleaseEvent(QMouseEvent * e)
virtual voidresizeEvent(QResizeEvent * e)
virtual voidshowEvent(QShowEvent *)
  • 26 protected functions inherited fromQ3ScrollView
  • 5 protected functions inherited fromQ3Frame
  • 3 protected functions inherited fromQFrame
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Additional Inherited Members

  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject
  • 1 protected slot inherited fromQWidget

Detailed Description

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.

Screenshot in Motif styleScreenshot in Windows style

See alsoQ3ListView,QComboBox, andQButtonGroup.

Member Type Documentation

typedef Q3ListBox::ComparisonFlags

This typedef is used inQ3IconView's API for values that are OR'd combinations ofStringComparisonMode values.

See alsoStringComparisonMode.

enum Q3ListBox::LayoutMode

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

ConstantValueDescription
Q3ListBox::FixedNumber0There is a fixed number of rows (or columns).
Q3ListBox::FitToWidth1There are as many columns as will fit on-screen.
Q3ListBox::FitToHeightFitToWidthThere 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.

enum Q3ListBox::SelectionMode

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

ConstantValueDescription
Q3ListBox::Single0When 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::Multi1When the user selects an item the selection status of that item is toggled and the other items are left alone.
Q3ListBox::Extended2When 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::NoSelection3Items 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.

enum Q3ListBox::StringComparisonMode

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

ConstantValueDescription
Q3ListBox::CaseSensitive0x00001The strings must match case sensitively.
Q3ListBox::ExactMatch0x00010The target and search strings must match exactly.
Q3ListBox::BeginsWith0x00002The target string begins with the search string.
Q3ListBox::EndsWith0x00004The target string ends with the search string.
Q3ListBox::Contains0x00008The 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.

Property Documentation

columnMode :LayoutMode

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

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

Access functions:

LayoutModecolumnMode() const
virtual voidsetColumnMode(LayoutMode)
virtual voidsetColumnMode(int)

See alsosetRowMode(),rowMode, andnumColumns.

count : constuint

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

Access functions:

uintcount() const

currentItem :int

This property holds the current highlighted item.

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

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

Access functions:

intcurrentItem() const
virtual voidsetCurrentItem(int index)
virtual voidsetCurrentItem(Q3ListBoxItem * i)

currentText : constQString

This property holds the text of the current item.

This is equivalent to text(currentItem()).

Access functions:

QStringcurrentText() const

multiSelection :bool

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:

boolisMultiSelection() const
voidsetMultiSelection(bool multi)

See alsoselectionMode.

numColumns : constint

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:

intnumColumns() const

See alsocolumnMode,rowMode, andnumRows.

numItemsVisible : constint

This property holds the number of visible items.

Both partially and entirely visible items are counted.

Access functions:

intnumItemsVisible() const

numRows : constint

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:

intnumRows() const

See alsocolumnMode,rowMode, andnumColumns.

rowMode :LayoutMode

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:

LayoutModerowMode() const
virtual voidsetRowMode(LayoutMode)
virtual voidsetRowMode(int)

See alsocolumnMode.

selectionMode :SelectionMode

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:

SelectionModeselectionMode() const
virtual voidsetSelectionMode(SelectionMode)

See alsoSelectionMode.

topItem :int

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

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

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

Access functions:

inttopItem() const
virtual voidsetTopItem(int index)

variableHeight :bool

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

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

Access functions:

boolvariableHeight() const
virtual voidsetVariableHeight(bool)

See alsovariableWidth.

variableWidth :bool

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

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

Access functions:

boolvariableWidth() const
virtual voidsetVariableWidth(bool)

See alsovariableHeight.

Member Function Documentation

Q3ListBox::Q3ListBox(QWidget * parent = 0, constchar * name = 0,Qt::WindowFlags f = 0)

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.

Q3ListBox::~Q3ListBox()

Destroys the list box. Deletes all list box items.

bool Q3ListBox::autoBottomScrollBar() const

UsehScrollBarMode() instead. Returns true if the horizontal scrollbar mode is set toAuto.

See alsosetAutoBottomScrollBar().

bool Q3ListBox::autoScroll() const

UsedragAutoScroll() instead. This function always returns true.

See alsosetAutoScroll().

bool Q3ListBox::autoScrollBar() const

UsevScrollBarMode() instead. Returns true if the vertical scrollbar mode isAuto.

See alsosetAutoScrollBar().

bool Q3ListBox::autoUpdate() const

Returns true. Qt always updates automatically.

See alsosetAutoUpdate().

bool Q3ListBox::bottomScrollBar() const

UsehScrollBarMode() instead. Returns true if the horizontal scrollbar mode is notAlwaysOff.

See alsosetBottomScrollBar().

int Q3ListBox::cellHeight(int i) const

UseitemHeight(i) instead.

int Q3ListBox::cellHeight() const

UseitemHeight() instead.

int Q3ListBox::cellWidth() const

UsemaxItemWidth() instead.

int Q3ListBox::cellWidth(int i) const

UsemaxItemWidth(i) instead.

void Q3ListBox::centerCurrentItem()

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().

void Q3ListBox::changeItem(constQ3ListBoxItem * lbi,int index)

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().

void Q3ListBox::changeItem(constQString & text,int index)

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().

void Q3ListBox::changeItem(constQPixmap & pixmap,int index)

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().

void Q3ListBox::changeItem(constQPixmap & pixmap, constQString & text,int index)

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() 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. Ifitem is not 0, the cursor is onitem. Ifitem is 0, the mouse cursor isn't on any item.

bool Q3ListBox::dragSelect() const

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().

Q3ListBoxItem * Q3ListBox::findItem(constQString & text,ComparisonFlags compare = BeginsWith) const

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) const

Use index(itemAt(yPos)) instead.

Q3ListBoxItem * Q3ListBox::firstItem() const

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().

int Q3ListBox::inSort(constQ3ListBoxItem * lbi)

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().

int Q3ListBox::inSort(constQString & text)

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().

int Q3ListBox::index(constQ3ListBoxItem * lbi) const

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) const

Reimplemented fromQWidget::inputMethodQuery().

void Q3ListBox::insertItem(constQ3ListBoxItem * lbi,int index = -1)

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().

void Q3ListBox::insertItem(constQ3ListBoxItem * lbi, constQ3ListBoxItem * after)

This is an overloaded function.

Inserts the itemlbi into the list after the itemafter, or at the beginning ifafter is 0.

See alsoinsertStrList().

void Q3ListBox::insertItem(constQString & text,int index = -1)

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().

void Q3ListBox::insertItem(constQPixmap & pixmap,int index = -1)

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().

void Q3ListBox::insertItem(constQPixmap & pixmap, constQString & text,int index = -1)

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().

void Q3ListBox::insertStrList(constchar ** strings,int numStrings = -1,int index = -1)

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().

void Q3ListBox::insertStringList(constQStringList & list,int index = -1)

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

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

bool Q3ListBox::isSelected(int i) const

Returns true if itemi is selected; otherwise returns false.

bool Q3ListBox::isSelected(constQ3ListBoxItem * i) const

This is an overloaded function.

Returns true if itemi is selected; otherwise returns false.

Q3ListBoxItem * Q3ListBox::item(int index) const

Returns a pointer to the item at positionindex, or 0 ifindex is out of bounds.

See alsoindex().

Q3ListBoxItem * Q3ListBox::itemAt(constQPoint & p) const

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.

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

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

Ifindex is too large, this function returns 0.

QRect Q3ListBox::itemRect(Q3ListBoxItem * item) const

Returns the rectangle on the screen thatitem occupies inviewport()'s coordinates, or an invalid rectangle ifitem is 0 or is not currently visible.

bool Q3ListBox::itemVisible(int index)

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

bool Q3ListBox::itemVisible(constQ3ListBoxItem * item)

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().

long Q3ListBox::maxItemWidth() const

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

[virtual]QSize Q3ListBox::minimumSizeHint() const

Reimplemented 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().

int Q3ListBox::numCols() const

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.

constQPixmap * Q3ListBox::pixmap(int index) const

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().

void Q3ListBox::removeItem(int index)

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.

bool Q3ListBox::scrollBar() const

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().

Q3ListBoxItem * Q3ListBox::selectedItem() const

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

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

See 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().

void Q3ListBox::setAutoBottomScrollBar(bool enable)

UsesetHScrollBarMode() instead.

Ifenable is true, passAuto as the argument tosetHScrollBarMode(); otherwise, passAlwaysOff.

See alsoautoBottomScrollBar().

void Q3ListBox::setAutoScroll(bool b)

UsesetDragAutoScroll(b) instead.

See alsoautoScroll().

void Q3ListBox::setAutoScrollBar(bool enable)

UsesetVScrollBarMode() instead.

Ifenable is true, passAuto as the argument tosetVScrollBarMode(); otherwise, passAlwaysOff.

See alsoautoScrollBar().

void Q3ListBox::setAutoUpdate(bool b)

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().

void Q3ListBox::setBottomScrollBar(bool enable)

UsesetHScrollBarMode() instead.

Ifenable is true, passAlwaysOn as the argument tosetHScrollBarMode(); otherwise, passAlwaysOff.

See alsobottomScrollBar().

void Q3ListBox::setDragSelect(bool b)

Does nothing. Dragging always selects. Theb parameter is ignored.

See alsodragSelect().

void Q3ListBox::setFixedVisibleLines(int lines)

UsesetRowMode(lines) instead.

void Q3ListBox::setScrollBar(bool enable)

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().

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

This is an overloaded function.

Ifselect is true the item at positionindex is selected; otherwise the item is deselected.

void Q3ListBox::setSmoothScrolling(bool b)

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

Reimplemented fromQWidget::sizeHint().

bool Q3ListBox::smoothScrolling() const

Returns false. Qt always scrolls smoothly.

See alsosetSmoothScrolling().

void Q3ListBox::sort(bool ascending = true)

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.

void Q3ListBox::takeItem(constQ3ListBoxItem * item)

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().

QString Q3ListBox::text(int index) const

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

UsecontentsHeight() instead.

[protected]int Q3ListBox::totalWidth() const

UsecontentsWidth() instead.

void Q3ListBox::triggerUpdate(bool doLayout)

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.


[8]ページ先頭

©2009-2025 Movatter.jp