Q3ListBox Class | Qt 4.8 (original) (raw)
Member Function Documentation
Q3ListBox::Q3ListBox(QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0)
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.
Q3ListBox::~Q3ListBox()
Destroys the list box. Deletes all list box items.
bool Q3ListBox::autoBottomScrollBar() const
Use hScrollBarMode() instead. Returns true if the horizontal scrollbar mode is set to Auto.
See also setAutoBottomScrollBar().
bool Q3ListBox::autoScroll() const
Use dragAutoScroll() instead. This function always returns true.
See also setAutoScroll().
bool Q3ListBox::autoScrollBar() const
Use vScrollBarMode() instead. Returns true if the vertical scrollbar mode is Auto.
See also setAutoScrollBar().
bool Q3ListBox::autoUpdate() const
Returns true. Qt always updates automatically.
See also setAutoUpdate().
bool Q3ListBox::bottomScrollBar() const
Use hScrollBarMode() instead. Returns true if the horizontal scrollbar mode is not AlwaysOff.
See also setBottomScrollBar().
int Q3ListBox::cellHeight(int i) const
Use itemHeight(i) instead.
int Q3ListBox::cellHeight() const
Use itemHeight() instead.
int Q3ListBox::cellWidth() const
Use maxItemWidth() instead.
int Q3ListBox::cellWidth(int i) const
Use maxItemWidth(i) instead.
void Q3ListBox::centerCurrentItem()
If there is a current item, the list box is scrolled so that this item is displayed centered.
See also Q3ListBox::ensureCurrentVisible().
[virtual protected] void Q3ListBox::changeEvent(QEvent * ev)
Reimplemented from QWidget::changeEvent().
void Q3ListBox::changeItem(const Q3ListBoxItem * lbi, int index)
Replaces the item at position index with lbi. If index is negative or too large, changeItem() does nothing.
The item that has been changed will become selected.
See also insertItem() and removeItem().
void Q3ListBox::changeItem(const QString & text, int index)
This is an overloaded function.
Replaces the item at position index with a new list box text item with text text.
The operation is ignored if index is out of range.
See also insertItem() and removeItem().
void Q3ListBox::changeItem(const QPixmap & pixmap, int index)
This is an overloaded function.
Replaces the item at position index with a new list box pixmap item with pixmap pixmap.
The operation is ignored if index is out of range.
See also insertItem() and removeItem().
void Q3ListBox::changeItem(const QPixmap & pixmap, const QString & text, int index)
This is an overloaded function.
Replaces the item at position index with a new list box pixmap item with pixmap pixmap and text text.
The operation is ignored if index is out of range.
See also insertItem() and removeItem().
[slot] void Q3ListBox::clear()
Deletes all the items in the list.
See also removeItem().
[virtual slot] void Q3ListBox::clearSelection()
Deselects all items, if possible.
Note that a 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. If 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.
**Note:**Signal clicked 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:
[signal] void Q3ListBox::clicked(Q3ListBoxItem * item, const QPoint & pnt)
This is an overloaded function.
This signal is emitted when the user clicks any mouse button. If item is not 0, the cursor is on item. If 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.
**Note:**Signal clicked 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:
[virtual protected] void Q3ListBox::contentsContextMenuEvent(QContextMenuEvent * e)
Reimplemented from Q3ScrollView::contentsContextMenuEvent().
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.
See also setCurrentItem() and 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. If item is 0, the mouse cursor isn't on any item.
bool Q3ListBox::dragSelect() const
Returns true. Dragging always selects.
See also setDragSelect().
[virtual slot] void Q3ListBox::ensureCurrentVisible()
Ensures that the current item is visible.
[virtual protected] bool Q3ListBox::eventFilter(QObject * o, QEvent * e)
Reimplemented from QObject::eventFilter().
Q3ListBoxItem * Q3ListBox::findItem(const QString & text, ComparisonFlags compare = BeginsWith) const
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.
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 from QWidget::focusInEvent().
[virtual protected] void Q3ListBox::focusOutEvent(QFocusEvent * e)
Reimplemented from 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.
**Note:**Signal highlighted 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:
See also currentChanged(), selected(), currentItem(), and selectionChanged().
[signal] void Q3ListBox::highlighted(Q3ListBoxItem * item)
This is an overloaded function.
This signal is emitted when the user makes a new item the current item.
**Note:**Signal highlighted 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:
See also currentChanged(), selected(), currentItem(), and selectionChanged().
[signal] void Q3ListBox::highlighted(const QString & 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's text.
**Note:**Signal highlighted 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:
See also currentChanged(), selected(), currentItem(), and selectionChanged().
int Q3ListBox::inSort(const Q3ListBoxItem * lbi)
Using this method is quite inefficient. We suggest to use insertItem() for inserting and sort() afterwards.
Inserts 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.
See also insertItem() and sort().
int Q3ListBox::inSort(const QString & text)
This is an overloaded function.
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.
See also insertItem() and sort().
int Q3ListBox::index(const Q3ListBoxItem * lbi) const
Returns the index of lbi, or -1 if the item is not in this list box or lbi is 0.
See also item().
[virtual] QVariant Q3ListBox::inputMethodQuery(Qt::InputMethodQuery query) const
Reimplemented from QWidget::inputMethodQuery().
void Q3ListBox::insertItem(const Q3ListBoxItem * lbi, int index = -1)
Inserts the item lbi into the list at position index.
If index is negative or larger than the number of items in the list box, lbi is inserted at the end of the list.
See also insertStrList().
void Q3ListBox::insertItem(const Q3ListBoxItem * lbi, const Q3ListBoxItem * after)
This is an overloaded function.
Inserts the item lbi into the list after the item after, or at the beginning if after is 0.
See also insertStrList().
void Q3ListBox::insertItem(const QString & text, int index = -1)
This is an overloaded function.
Inserts a new list box text item with the text text into the list at position index.
If index is negative, text is inserted at the end of the list.
See also insertStrList().
void Q3ListBox::insertItem(const QPixmap & pixmap, int index = -1)
This is an overloaded function.
Inserts a new list box pixmap item with the pixmap pixmap into the list at position index.
If index is negative, pixmap is inserted at the end of the list.
See also insertStrList().
void Q3ListBox::insertItem(const QPixmap & pixmap, const QString & text, int index = -1)
This is an overloaded function.
Inserts a new list box pixmap item with the pixmap pixmap and the text text into the list at position index.
If index is negative, pixmap is inserted at the end of the list.
See also insertStrList().
void Q3ListBox::insertStrList(const char ** strings, int numStrings = -1, int index = -1)
Inserts the numStrings strings of the array strings into the list at position index.
If index is negative, insertStrList() inserts strings at the end of the list. If index is too large, the operation is ignored.
Warning: This function uses const char * rather than QString, so we recommend against using it. It is provided so that legacy code will continue to work, and so that programs that certainly will not need to handle code outside a single 8-bit locale can use it. See insertStringList() which uses real QStrings.
Warning: This function is never significantly faster than a loop around insertItem().
See also insertItem() and insertStringList().
void Q3ListBox::insertStringList(const QStringList & list, int index = -1)
Inserts the string list list into the list at position index.
If index is negative, list is inserted at the end of the list. If index is too large, the operation is ignored.
Warning: This function is never significantly faster than a loop around insertItem().
See also insertItem() and insertStrList().
[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.
bool Q3ListBox::isSelected(int i) const
Returns true if item i is selected; otherwise returns false.
bool Q3ListBox::isSelected(const Q3ListBoxItem * i) const
This is an overloaded function.
Returns true if item i is selected; otherwise returns false.
Q3ListBoxItem * Q3ListBox::item(int index) const
Returns a pointer to the item at position index, or 0 if index is out of bounds.
See also index().
Q3ListBoxItem * Q3ListBox::itemAt(const QPoint & p) const
Returns the item at point p, specified in viewport coordinates, or a 0 if there is no item at p.
Use contentsToViewport() to convert between widget coordinates and viewport coordinates.
int Q3ListBox::itemHeight(int index = 0) const
Returns the height in pixels of the item with index index. index defaults to 0.
If index is too large, this function returns 0.
QRect Q3ListBox::itemRect(Q3ListBoxItem * item) const
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.
bool Q3ListBox::itemVisible(int index)
Returns true if the item at position index is at least partly visible; otherwise returns false.
bool Q3ListBox::itemVisible(const Q3ListBoxItem * item)
This is an overloaded function.
Returns true if item is at least partly visible; otherwise returns false.
[virtual protected] void Q3ListBox::keyPressEvent(QKeyEvent * e)
Reimplemented from QWidget::keyPressEvent().
long Q3ListBox::maxItemWidth() const
Returns the width of the widest item in the list box.
[virtual] QSize Q3ListBox::minimumSizeHint() const
Reimplemented from QWidget::minimumSizeHint().
[signal] void Q3ListBox::mouseButtonClicked(int button, Q3ListBoxItem * item, const QPoint & pos)
This signal is emitted when the user clicks mouse button button. If item is not 0, the cursor is on item. If 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. If item is not 0, the cursor is on item. If 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)
Reimplemented from QWidget::mouseDoubleClickEvent().
[virtual protected] void Q3ListBox::mouseMoveEvent(QMouseEvent * e)
Reimplemented from QWidget::mouseMoveEvent().
[virtual protected] void Q3ListBox::mousePressEvent(QMouseEvent * e)
Reimplemented from QWidget::mousePressEvent().
[virtual protected] void Q3ListBox::mouseReleaseEvent(QMouseEvent * e)
Reimplemented from QWidget::mouseReleaseEvent().
int Q3ListBox::numCols() const
Use numColumns() instead.
[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() function. i is the 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() instead.
Repaints the cell at row, col using painter p.
const QPixmap * Q3ListBox::pixmap(int index) const
Returns a pointer to the pixmap at position index, or 0 if there is no pixmap there.
See also 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. If 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.
**Note:**Signal pressed 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:
[signal] void Q3ListBox::pressed(Q3ListBoxItem * item, const QPoint & pnt)
This is an overloaded function.
This signal is emitted when the user presses any mouse button. If item is not 0, the cursor is on item. If 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.
**Note:**Signal pressed 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:
See also mouseButtonPressed(), rightButtonPressed(), and clicked().
void Q3ListBox::removeItem(int index)
Removes and deletes the item at position index. If index is equal to currentItem(), a new item becomes current and the currentChanged() and highlighted() signals are emitted.
See also insertItem() and clear().
[virtual protected] void Q3ListBox::resizeEvent(QResizeEvent * e)
Reimplemented from 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.
bool Q3ListBox::scrollBar() const
Use vScrollBarMode() instead. Returns true if the vertical scrollbar mode is not AlwaysOff.
See also setScrollBar().
[virtual slot] void Q3ListBox::selectAll(bool select)
In Multi and Extended modes, this function sets all items to be selected if select is true, and to be unselected if select is false.
In 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.
**Note:**Signal selected 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:
See also setSelected(), currentChanged(), highlighted(), and selectionChanged().
[signal] void Q3ListBox::selected(Q3ListBoxItem * item)
This is an overloaded function.
This signal is emitted when the user double-clicks on an item or presses Enter on the current item.
**Note:**Signal selected 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:
See also currentChanged(), highlighted(), and selectionChanged().
[signal] void Q3ListBox::selected(const QString & 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 the text of the selected item.
**Note:**Signal selected 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:
See also currentChanged(), highlighted(), and selectionChanged().
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 also setSelected() and 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.
**Note:**Signal selectionChanged 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:
See also selected() and currentItem().
[signal] void Q3ListBox::selectionChanged(Q3ListBoxItem * item)
This is an overloaded function.
This signal is emitted when the selection in a Single selection list box changes. item is the newly selected list box item.
**Note:**Signal selectionChanged 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:
See also selected() and currentItem().
void Q3ListBox::setAutoBottomScrollBar(bool enable)
Use setHScrollBarMode() instead.
If enable is true, pass Auto as the argument to setHScrollBarMode(); otherwise, pass AlwaysOff.
See also autoBottomScrollBar().
void Q3ListBox::setAutoScroll(bool b)
Use setDragAutoScroll(b) instead.
See also autoScroll().
void Q3ListBox::setAutoScrollBar(bool enable)
Use setVScrollBarMode() instead.
If enable is true, pass Auto as the argument to setVScrollBarMode(); otherwise, pass AlwaysOff.
See also autoScrollBar().
void Q3ListBox::setAutoUpdate(bool b)
Does nothing. Qt always updates automatically. The b parameter is ignored.
See also autoUpdate().
[virtual] 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.
See also setTopItem().
void Q3ListBox::setBottomScrollBar(bool enable)
Use setHScrollBarMode() instead.
If enable is true, pass AlwaysOn as the argument to setHScrollBarMode(); otherwise, pass AlwaysOff.
See also bottomScrollBar().
void Q3ListBox::setDragSelect(bool b)
Does nothing. Dragging always selects. The b parameter is ignored.
See also dragSelect().
void Q3ListBox::setFixedVisibleLines(int lines)
Use setRowMode(lines) instead.
void Q3ListBox::setScrollBar(bool enable)
Use setVScrollBarMode() instead.
If enable is true, pass AlwaysOn as the argument to setVScrollBarMode(); otherwise, pass AlwaysOff.
See also scrollBar().
[virtual] void Q3ListBox::setSelected(Q3ListBoxItem * item, bool select)
Selects 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().
See also selected(), setMultiSelection(), setCurrentItem(), clearSelection(), and currentItem().
void Q3ListBox::setSelected(int index, bool select)
This is an overloaded function.
If select is true the item at position index is selected; otherwise the item is deselected.
void Q3ListBox::setSmoothScrolling(bool b)
Does nothing. Qt always scrolls smoothly. The b parameter is ignored.
See also smoothScrolling().
[virtual protected] void Q3ListBox::showEvent(QShowEvent *)
Reimplemented from QWidget::showEvent().
[virtual] QSize Q3ListBox::sizeHint() const
Reimplemented from QWidget::sizeHint().
bool Q3ListBox::smoothScrolling() const
Returns false. Qt always scrolls smoothly.
See also setSmoothScrolling().
void Q3ListBox::sort(bool ascending = true)
If 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.
void Q3ListBox::takeItem(const Q3ListBoxItem * item)
Removes 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.
See also Q3ListBox::insertItem().
QString Q3ListBox::text(int index) const
Returns the text at position index, or an empty string if there is no text at that position.
See also pixmap().
[protected] void Q3ListBox::toggleCurrentItem()
Toggles the selection status of currentItem() and repaints if the list box is a Multi selection list box.
See also setMultiSelection().
[protected] int Q3ListBox::totalHeight() const
Use contentsHeight() instead.
[protected] int Q3ListBox::totalWidth() const
Use contentsWidth() instead.
void Q3ListBox::triggerUpdate(bool doLayout)
Ensures that a single paint event will occur at the end of the current event loop iteration. If doLayout is true, the layout is also redone.
[protected] void Q3ListBox::updateCellWidth()
Does nothing. Qt automatically updates.
[protected] void Q3ListBox::updateItem(int index)
Repaints the item at position index in the list.
[protected] void Q3ListBox::updateItem(Q3ListBoxItem * i)
This is an overloaded function.
Repaints the Q3ListBoxItem i.
[virtual] void Q3ListBox::viewportPaintEvent(QPaintEvent * e)
Reimplemented from Q3ScrollView::viewportPaintEvent().