QListBox - List of selectable, read-only items
#include <qlistbox.h>
Inherits QScrollView.
Public Members
QListBox ( QWidget * parent=0, const char * name=0, WFlags
f=0 )
~QListBox ()
uint count () const
void insertStringList ( const QStringList &, int index=-1
)
void insertStrList ( const QStrList *, int index=-1 )
void insertStrList ( const QStrList &, int index=-1 )
void insertStrList ( const char **, int numStrings=-1, int
index=-1 )
void insertItem ( const QListBoxItem *, int index=-1 )
void insertItem ( const QListBoxItem *, const QListBoxItem
* 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 removeItem ( int index )
void clear ()
QString text ( int index ) const
const QPixmap* pixmap ( int index ) const
void changeItem ( const QListBoxItem *, 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 )
void takeItem ( const QListBoxItem * )
int numItemsVisible () const
int currentItem () const
QString currentText () const
virtual void setCurrentItem ( int index )
virtual void setCurrentItem ( QListBoxItem * )
void centerCurrentItem ()
int topItem () const
virtual void setTopItem ( int index )
virtual void setBottomItem ( int index )
long maxItemWidth () const
enum SelectionMode { Single, Multi, Extended, NoSelection
}
virtual void setSelectionMode ( SelectionMode )
SelectionMode selectionMode () const
void setMultiSelection ( bool multi ) (obsolete)
bool isMultiSelection () const (obsolete)
virtual void setSelected ( QListBoxItem *, bool )
void setSelected ( int, bool )
bool isSelected ( const QListBoxItem * ) const
QListBoxItem* item ( int index ) const
int index ( const QListBoxItem * ) const
QListBoxItem* findItem ( const QString & text ) const
void triggerUpdate ( bool doLayout )
bool itemVisible ( int index )
bool itemVisible ( const QListBoxItem * )
enum LayoutMode { FixedNumber, FitToWidth, FitToHeight =
FitToWidth, Variable }
virtual void setColumnMode ( LayoutMode )
virtual void setColumnMode ( int )
virtual void setRowMode ( LayoutMode )
virtual void setRowMode ( int )
LayoutMode columnMode () const
LayoutMode rowMode () const
int numColumns () const
int numRows () const
bool variableWidth () const
virtual void setVariableWidth ( bool )
bool variableHeight () const
virtual void setVariableHeight ( bool )
int itemHeight ( int index = 0 ) const
QListBoxItem* itemAt ( QPoint ) const
QRect itemRect ( QListBoxItem * item ) const
QListBoxItem* firstItem () const
void sort ( bool ascending = TRUE )
Public Slots
virtual void ensureCurrentVisible ()
virtual void clearSelection ()
void selectAll ( bool select )
void invertSelection ()
Signals
void highlighted ( int index )
void selected ( int index )
void highlighted ( const QString & )
void selected ( const QString & )
void highlighted ( QListBoxItem * )
void selected ( QListBoxItem * )
void selectionChanged ()
void selectionChanged ( QListBoxItem * )
void currentChanged ( QListBoxItem * )
void clicked ( QListBoxItem * )
void clicked ( QListBoxItem *, const QPoint & )
void pressed ( QListBoxItem * )
void pressed ( QListBoxItem *, const QPoint & )
void doubleClicked ( QListBoxItem * )
void returnPressed ( QListBoxItem * )
void rightButtonClicked ( QListBoxItem *, const QPoint & )
void rightButtonPressed ( QListBoxItem *, const QPoint & )
void mouseButtonPressed ( int, QListBoxItem *, const
QPoint & )
QPoint & )
void onItem ( QListBoxItem * item )
void onViewport ()
Protected Members
void updateItem ( int index )
void updateItem ( QListBoxItem * )
virtual void paintCell ( QPainter *, int row, int col )
void toggleCurrentItem ()
bool isRubberSelecting () const
void doLayout () const
Protected Slots
void clearInputString () (internal)
Properties
Type Name READ WRITE Options
------------------------------------------------------------------------------------------
uint count count
int numItemsVisible numItemsVisible
int currentItem currentItem setCurrentItem DESIGNABLE false
QString currentText currentText
int topItem topItem setTopItem DESIGNABLE false
SelectionMode selectionMode selectionMode setSelectionMode
bool multiSelection isMultiSelection setMultiSelection DESIGNABLE false
LayoutMode columnMode columnMode setColumnMode
LayoutMode rowMode rowMode setRowMode
int numColumns numColumns
int numRows numRows
bool variableWidth variableWidth setVariableWidth
bool variableHeight variableHeight setVariableHeight
DESCRIPTION
The QListBox widget provides a list of selectable, read-
only items.
This is typically a single-column list where zero or one
items are selected at once, but can also be used in many
other ways.
QListBox will add scroll bars as necessary, but 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, chiefly because the scroll bars won't provide very
good navigation, but also because QListBox may become slow
at larger sizes.
There is a variety of selection modes, described in the
QListBox::SelectionMode documentation. The default is
single-selection, and you can change it using
setSelectionMode(). For compatibility with previous Qt
versions there is still the setMultiSelection() methode.
setSelectionMode( Multi ), and setMultiSelection( FALSE )
is equivalent to setSelectionMode( Single ). It's
suggested not to use setMultiSelection() anymore, but to
use setSelectionMode() instead.
Since QListBox offers multiple selection it has to display
keyboard focus and selection state separately. Therefore
there are functions both to set the selection state of an
item, setSelected(), and to select which item displays
keyboard focus, setCurrentItem().
The list box normally arranges its items in a single
column with a vertical scroll bar if necessary, but it is
also possible to have a different fixed number of columns
(setColumnMode()), or as many columns as will fit in the
list box' 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' assigned screen
space (setRowMode( FitToHeight )). In all these cases,
QListBox will add scroll bars as appropriate in at least
one direction.
If multiple rows is 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 ). Of course there is a similar
setVariableWidth().
The items discussed are QListBoxItem objects. QListBox
provides methods to insert new items as a string, as
pixmaps, and as QListBoxItem * (insertItem() with various
arguments), and to replace an existing item with a new
string, pixmap or QListBoxItem (changeItem() with various
arguments). You can also remove items (surprise:
removeItem()) and clear() the entire list box. Note that
if you create a QListBoxItem yourself and insert it, it
becomes the property of QListBox and you may not delete
it. (QListBox will delete it when appropriate.)
You can also create a QListBoxItem such as QListBoxText or
QListBoxPixmap with the list box as first parameter. The
item will then append itself. When you delete an item, it
is automatically removed from the listbox.
The list of items can be arbitrarily big; if necessary,
QListBox adds scroll bars. It can be single-column (as
most list boxes are) or multi-column, and offers both
single and multiple selection. (QListBox does however not
support multiple-column items; QListView does that job.)
Also a listbox can display items arranged in a tree. But
this is quite limited, and if you really want to display
and work with a tree, you should use a QListView. The tree
stuff in the QListBox is only supported because itīs
The list box items can be accessed both as QListBoxItem
objects (recommended) and using integer indexes (the
original QListBox implementation used an array of strings
internally, and the API still supports this mode of
operation). Everything can be done using the new objects;
most things can be done using the indexes too but
unfortunately not everything.
Each item in a QListBox contains a QListBoxItem. One of
the items can be the current item. The highlighted()
signal is emitted when a new item gets highlighted, e.g.
because the user clicks on it or
QListBox::setCurrentItem() is called. The selected()
signal is emitted when the user double-clicks on an item
or presses return when an item is highlighted.
If the user does not select anything, no signals are
emitted and currentItem() returns -1.
A list box has WheelFocus as a default focusPolicy(), i.e.
it can get keyboard focus both by tabbing, clicking and
the mouse wheel.
New items may be inserted using either insertItem(),
insertStrList() or insertStringList(). inSort() is
obsolete, as this method is quite inefficient. It's
preferable to insert the items normally and call sort()
afterwards, or insert a sorted QStringList().
By default, vertical and horizontal scroll bars are added
and removed as necessary. setHScrollBarMode() and
setVScrollBarMode() can be used to change this policy.
If you need to insert other types than texts and pixmaps,
you must define new classes which inherit QListBoxItem.
Warning: The list box assumes ownership of all list box
items and will delete them when it does not need them any
more.
[Image Omitted]
[Image Omitted]
See also QListView, QComboBox, QButtonGroup and GUI Design
Handbook: List Box (two sections)
Member Type Documentation
QListBox::LayoutMode
This enum type decides how QListBox lays out its rows and
columns. The two modes interact, of course.
FixedNumber - there is a fixed number of rows (or
columns).
FitToHeight - there are as many rows as will fit on-
screen. (Ditto with FitToWidth and columns.)
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 Variable to accomodate
the row mode you've set.
QListBox::SelectionMode
This enumerated type is used by QListBox to indicate how
it reacts to selection by the user. It has four values:
Single - 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
QListBox::clearSelection().
Multi - When the user selects an item in the most ordinary
way, the selection status of that item is toggled
and the other items are left alone.
Extended - When the user selects an item in the most
ordinary way, 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
stayes pressed.
NoSelection - Items cannot be selected.
In other words, Single is a real single-selection list
box, Multi a real multi-selection list box, and Extended
list box where 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
MEMBER FUNCTION DOCUMENTATION
QListBox::QListBox ( QWidget * parent=0, const char * name=0,
WFlags f=0 )
Constructs a new empty list box, with parent as a parent
and name as object name.
Performance is boosted by modifying the widget flags f so
that only part of the QListBoxItem children is redrawn.
This may be unsuitable for custom QListBoxItem classes, in
which case WNorthWestGravity and WRepaintNoErase should be
cleared.
See also QWidget::clearWFlags() and Qt::WidgetFlags.
QListBox::~QListBox ()
Destroys the list box. Deletes all list box items.
void QListBox::centerCurrentItem ()
If there is a current item, the listbox is scrolled, so
that this item is displayed centered.
See also QListBox::ensureCurrentVisible().
void QListBox::changeItem ( const QListBoxItem * lbi, int index )
Replaces the item at position index with lbi. If index is
negative or too large, changeItem() does nothing.
See also insertItem() and removeItem().
void QListBox::changeItem ( const QPixmap & pixmap, const QString
& text, int index )
Replaces the item at position index with pixmap and text.
The operation is ignored if index is out of range.
See also insertItem() and removeItem().
void QListBox::changeItem ( const QPixmap & pixmap, int index )
Replaces the item at position index with pixmap.
The operation is ignored if index is out of range.
See also insertItem() and removeItem().
void QListBox::changeItem ( const QString & text, int index )
Replaces the item at position index with text.
The operation is ignored if index is out of range.
See also insertItem() and removeItem().
Deletes all items in the list.
See also removeItem().
void QListBox::clearSelection () [virtual slot]
Deselects all items, if possible.
Note that a single-selection listbox will automatically
select an item if it has keyboard focus.
void QListBox::clicked ( QListBoxItem * item ) [signal]
This signal is emitted whenever the user clicks (mouse
pressed + mouse released) into the listbox. item is the
pointer to the clicked listbox item or NULL, if the user
didn't click on an item.
Note that you may not delete any QListBoxItem objects in
slots connected to this signal.
void QListBox::clicked ( QListBoxItem * item, const QPoint & pnt
) [signal]
This signal is emitted whenever the user clicks (mouse
pressed + mouse released) into the listbox. item is the
pointer to the clicked listbox item or NULL, if the user
didn't click on an item. pnt is the position where the
user has clicked.
Note that you may not delete any QListBoxItem objects in
slots connected to this signal.
QListBox::LayoutMode QListBox::columnMode() const
Returns the column layout mode for this list box. This is
normally FixedNumber, but can be changed by calling
setColumnMode()
See also rowMode(), setColumnMode() and numColumns().
uint QListBox::count () const
Returns the number of items in the list box.
void QListBox::currentChanged ( QListBoxItem * item ) [signal]
This signal is emitted when the user highlights a new
current item. The argument is the index of the new item,
which is already current.
See also setCurrentItem() and currentItem().
int QListBox::currentItem () const
Returns the index of the current (highlighted) item of the
list box, or -1 if no item has been selected.
See also topItem().
Returns the text of the current item.
This is equivalent to text(currentItem()).
void QListBox::doLayout () const [protected]
This function does the hard layout work. You should never
need to call it.
void QListBox::doubleClicked ( QListBoxItem * item ) [signal]
This signal is emitted whenever an item is double-clicked.
It's emitted on the second button press, not the second
button release. item is the listbox item onto which the
user did the double click.
void QListBox::ensureCurrentVisible () [virtual slot]
Ensures that the current item is visible.
QListBoxItem * QListBox::findItem ( const QString & text ) const
Finds the first listbox item which starts with text and
returns it, or returns 0 of no such item could be found.
The search is done case-insensitive.
QListBoxItem * QListBox::firstItem () const
Returns the first item of this listbox.
void QListBox::focusInEvent ( QFocusEvent * e ) [virtual
protected]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QWidget.
void QListBox::focusOutEvent ( QFocusEvent * ) [virtual
protected]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QWidget.
void QListBox::highlighted ( QListBoxItem * ) [signal]
This signal is emitted when the user highlights a new
current item. The argument is a pointer to the new current
item.
See also selected(), currentItem() and selectionChanged().
void QListBox::highlighted ( const QString & ) [signal]
This signal is emitted when the user highlights a new
current item and the new item is a string. The argument is
the text of the new current item.
See also selected(), currentItem() and selectionChanged().
This signal is emitted when the user highlights a new
current item. The argument is the index of the new item,
which is already current.
See also selected(), currentItem() and selectionChanged().
int QListBox::index ( const QListBoxItem * lbi ) const
Returns the index of lbi, or -1 if the item is not in this
list box or lbi is a NULL-Pointer.
See also item().
void QListBox::insertItem ( const QListBoxItem * lbi, const
QListBoxItem * after )
Inserts the item lbi into the list after the item after.
If after is NULL, lbi is inserted at the beginning.
See also insertStrList().
void QListBox::insertItem ( const QListBoxItem * lbi, int
index=-1 )
Inserts the item lbi into the list at index.
If index is negative or larger than the number of items in
the list box, lbi is inserted at the end of the list.
See also insertStrList().
void QListBox::insertItem ( const QPixmap & pixmap, const QString
& text, int index=-1 )
Inserts pixmap and text into the list at index.
If index is negative, pixmap is inserted at the end of the
list.
See also insertStrList().
void QListBox::insertItem ( const QPixmap & pixmap, int index=-1
)
Inserts pixmap into the list at index.
If index is negative, pixmap is inserted at the end of the
list.
See also insertStrList().
void QListBox::insertItem ( const QString & text, int index=-1 )
Inserts text into the list at index.
If index is negative, text is inserted at the end of the
list.
void QListBox::insertStrList ( const QStrList & list, int
index=-1 )
Inserts the string list list into the list at item index.
If index is negative, list is inserted at the end of the
list. If index is too large, the operation is ignored.
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() - it uses real QStrings.
Warning: This function is never significantly faster than
a loop around insertItem().
See also insertItem() and insertStringList().
void QListBox::insertStrList ( const QStrList * list, int
index=-1 )
Inserts the string list list into the list at item index.
If index is negative, list is inserted at the end of the
list. If index is too large, the operation is ignored.
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() - it uses real QStrings.
Warning: This function is never significantly faster than
a loop around insertItem().
See also insertItem() and insertStringList().
void QListBox::insertStrList ( const char ** strings, int
numStrings=-1, int index=-1 )
Inserts the numStrings strings of the array strings into
the list at itemindex.
If index is negative, insertStrList() inserts strings at
the end of the list. If index is too large, the operation
is ignored.
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
Warning: This function is never significantly faster than
a loop around insertItem().
See also insertItem() and insertStringList().
void QListBox::insertStringList ( const QStringList & list, int
index=-1 )
Inserts the string list list into the list at item index.
If index is negative, list is inserted at the end of the
list. If index is too large, the operation is ignored.
Warning: This function is never significantly faster than
a loop around insertItem().
See also insertItem() and insertStrList().
void QListBox::invertSelection () [slot]
Inverts the selection. Works only in Multi and Extended
selection mode.
bool QListBox::isMultiSelection () const
This function is obsolete. It is provided to keep old
source working, and will probably be removed in a future
version of Qt. We strongly advise against using it in new
code.
Consider using selectionMode() instead of this method.
Returns TRUE if the listbox is in multi-selection mode or
extended selection mode, and FALSE if it is in single-
selection mode or no-selection more.
See also selectionMode() and setSelectionMode().
bool QListBox::isRubberSelecting () const [protected]
Returns whether the user is selecting items using a rubber
rectangle.
bool QListBox::isSelected ( const QListBoxItem * i ) const
Returns TRUE if item i is selected. Returns FALSE if it is
not selected or if there is an error.
bool QListBox::isSelected ( int i ) const
Returns TRUE if item i is selected. Returns FALSE if it is
not selected or if there is an error.
QListBoxItem * QListBox::item ( int index ) const
Returns a pointer to the item at position index, or 0 if
index is out of bounds.
See also index().
Returns a pointer to the item at p, which is in on-screen
coordinates, or a null pointer if there is no item at p.
int QListBox::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 QListBox::itemRect ( QListBoxItem * item ) const
Returns the rectangle on the screen item occupies in
viewport()'s coordinates, or an invalid rectangle if i is
a null pointer or is not currently visible.
bool QListBox::itemVisible ( const QListBoxItem * item )
Returns TRUE if item is at least partly visible, or else
FALSE.
bool QListBox::itemVisible ( int index )
Returns TRUE if the item at position index is at least
partly visible.
void QListBox::keyPressEvent ( QKeyEvent * e ) [virtual
protected]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QWidget.
long QListBox::maxItemWidth () const
Returns the width of the largest item in the listbox.
QSize QListBox::minimumSizeHint () const [virtual]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QWidget.
void QListBox::mouseButtonClicked ( int button, QListBoxItem *
item, const QPoint & pos ) [signal]
This signal is emitted whenever the user clicks (mouse
pressed + mouse released) into the listbox. button is the
mouse button, which the user pressed. item is the pointer
to the clicked listbox item or NULL, if the user didn't
click on an item. pos is the position where the user has
clicked.
Note that you may not delete any QListBoxItem objects in
slots connected to this signal.
void QListBox::mouseButtonPressed ( int button, QListBoxItem *
item, const QPoint & pos ) [signal]
This signal is emitted whenever the user presses the mouse
user pressed. item is the pointer to the listbox item onto
which the user pressed the mouse button or NULL, if the
user didn't press the mouse on an item. pos is the
position of the mouse cursor where the mouse cursor was
when the user pressed the mouse button.
Note that you may not delete any QListBoxItem objects in
slots connected to this signal.
void QListBox::mouseDoubleClickEvent ( QMouseEvent * e ) [virtual
protected]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QWidget.
void QListBox::mouseMoveEvent ( QMouseEvent * e ) [virtual
protected]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QWidget.
void QListBox::mousePressEvent ( QMouseEvent * e ) [virtual
protected]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QWidget.
void QListBox::mouseReleaseEvent ( QMouseEvent * e ) [virtual
protected]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QWidget.
int QListBox::numColumns () const
Returns the number of columns in the list box. This is
normally 1, but can be different if setColumnMode() or
setRowMode() has been called.
See also setColumnMode(), setRowMode() and numRows().
int QListBox::numItemsVisible () const
Returns the number of visible items. Both partially and
entirely visible items are counted.
int QListBox::numRows () const
Returns 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.
void QListBox::onItem ( QListBoxItem * i ) [signal]
This signal is emitted, when the user moves the mouse
cursor onto an item. Itīs only emitted once per item.
void QListBox::onViewport () [signal]
This signal is emitted, when the user moves the mouse
cursor, which was on an item away from the item onto the
viewport.
void QListBox::paintCell ( QPainter * p, int row, int col )
[virtual protected]
Provided for compatibility with the old QListBox. We
recommend using QListBoxItem::paint().
const QPixmap * QListBox::pixmap ( int index ) const
Returns a pointer to the pixmap at position index, or 0 if
there is no pixmap there.
See also text().
void QListBox::pressed ( QListBoxItem * item ) [signal]
This signal is emitted whenever the user presses the mouse
button on a listbox. item is the pointer to the listbox
item onto which the user pressed the mouse button or NULL,
if the user didn't press the mouse on an item.
Note that you may not delete any QListBoxItem objects in
slots connected to this signal.
void QListBox::pressed ( QListBoxItem * item, const QPoint & pnt
) [signal]
This signal is emitted whenever the user presses the mouse
button on a listbox. item is the pointer to the listbox
item onto which the user pressed the mouse button or NULL,
if the user didn't press the mouse on an item. pnt is the
position of the mouse cursor where the mouse cursor was
when the user pressed the mouse button.
Note that you may not delete any QListBoxItem objects in
slots connected to this signal.
void QListBox::removeItem ( int index )
Removes and deletes the item at position index. If index
is equal to currentItem(), a new item gets highlighted and
the highlighted() signal is emitted.
See also insertItem() and clear().
void QListBox::resizeEvent ( QResizeEvent * e ) [virtual
protected]
Reimplemented for internal reasons; the API is not
affected.
void QListBox::returnPressed ( QListBoxItem * ) [signal]
This signal is emitted when enter or return is pressed.
The argument is currentItem().
void QListBox::rightButtonClicked ( QListBoxItem *, const QPoint
& ) [signal]
This signal is emitted when the right button is clicked
(ie. when it's released). The arguments are the relevant
QListBoxItem (may be 0) and the point in global
coordinates.
void QListBox::rightButtonPressed ( QListBoxItem *, const QPoint
& ) [signal]
This signal is emitted when the right button is pressed.
Then arguments are the relevant QListBoxItem (may be 0)
and the point in global coordinates.
QListBox::LayoutMode QListBox::rowMode() const
Returns the row layout mode for this list box. This is
normally Variable, but can be changed by calling
setRowMode().
See also columnMode(), setRowMode() and numRows().
void QListBox::selectAll ( bool select ) [slot]
If select is TRUE, all items get selected, else all get
unselected. This works only in the selection modes Multi
and Extended. In Single and NoSelection mode the selection
of the current item is just set to select.
void QListBox::selected ( QListBoxItem * ) [signal]
This signal is emitted when the user double-clicks on an
item or presses return when an item is highlighted. The
argument is a pointer to the new selected item.
See also highlighted() and selectionChanged().
void QListBox::selected ( const QString & ) [signal]
This signal is emitted when the user double-clicks on an
item or presses return while an item is highlighted, and
the selected item is (or has) a string. The argument is
the text of the selected item.
See also highlighted() and selectionChanged().
void QListBox::selected ( int index ) [signal]
This signal is emitted when the user double-clicks on an
item or presses return when an item is highlighted. The
argument is the index of the selected item.
See also highlighted() and selectionChanged().
This signal is emitted when the selection set of a listbox
changes. This signal is emitted in each selection mode If
the user selects five items by drag-selecting, QListBox
tries to emit just one selectionChanged() signal, so the
signal can be connected to computationally expensive
slots.
See also selected() and currentItem().
void QListBox::selectionChanged ( QListBoxItem * item ) [signal]
This signal is emitted when the selection in a single-
selection listbox changes. item is the new selected
listbox item.
See also selected() and currentItem().
QListBox::SelectionMode QListBox::selectionMode() const
Returns the selection mode of the list box. The initial
mode is Single.
See also setSelectionMode().
void QListBox::setBottomItem ( int index ) [virtual]
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 QListBox::setColumnMode ( LayoutMode mode )
Sets the column layout mode to mode, and the number of
displayed columns accordingly.
The row layout mode implicitly becomes Variable.
If mode is Variable, this function returns without doing
anything.
See also setRowMode() and columnMode().
void QListBox::setColumnMode ( int columns ) [virtual]
Sets the column layout mode for this list box to
FixedNumber, and sets the number of displayed columns
accordingly.
See also setRowMode(), columnMode() and numColumns().
void QListBox::setCurrentItem ( QListBoxItem * i ) [virtual]
Sets the highlighted item to the item i. The highlighting
is moved and the list box scrolled as necessary.
See also currentItem().
This is an overloaded member function, provided for
convenience. It differs from the above function only in
what argument(s) it accepts.
This is a bit slower than the QListBoxItem * version.
void QListBox::setFont ( const QFont & font ) [virtual]
Reimplemented for internal reasons; the API is not
affected.
void QListBox::setMultiSelection ( bool enable )
This function is obsolete. It is provided to keep old
source working, and will probably be removed in a future
version of Qt. We strongly advise against using it in new
code.
Consider using setSelectionMode() instead of this method.
Sets the list box to multi-selection mode if enable is
TRUE, and to single-selection mode if enable is FALSE. We
recommend using setSelectionMode() instead; that function
also offers two other modes.
See also setSelectionMode() and selectionMode().
void QListBox::setRowMode ( LayoutMode mode )
Sets the row layout mode to mode, and the number of
displayed rows accordingly.
The column layout mode implicitly becomes Variable.
If mode is Variable, this function returns without doing
anything.
See also setColumnMode() and rowMode().
void QListBox::setRowMode ( int rows ) [virtual]
Sets the row layout mode for this list box to FixedNumber
and sets the number of displayed rows accordingly.
See also setColumnMode(), rowMode() and numRows().
void QListBox::setSelected ( QListBoxItem * item, bool select )
[virtual]
Selects item if select is TRUE, or unselects it if select
is FALSE, and repaints the item appropriately.
If the listbox is a single-selection listbox and and
select is TRUE, setCurrentItem() is called.
If the listbox is a single-selection listbox and and
select is FALSE, clearSelection() is called if index is
the currently selected item.
selection. The user cannot select items in a no-selection
list box, but the application programmer can.
See also setMultiSelection(), setCurrentItem(),
clearSelection() and currentItem().
void QListBox::setSelected ( int index, bool select )
Selects the item at position index if select is TRUE, or
unselects it if select is FALSE, and repaints the item
appropriately.
If the listbox is a single-selection listbox and and
select is TRUE, setCurrentItem() will be called.
If the listbox is a single-selection listbox and and
select is FALSE, clearSelection() will be called if index
is the currently selected item.
See also setMultiSelection(), setCurrentItem(),
clearSelection() and currentItem().
void QListBox::setSelectionMode ( SelectionMode mode )
Sets the list box to selection mode mode, which may be one
of Single (the default), Extended, Multi or NoSelection.
See also selectionMode().
void QListBox::setTopItem ( int index ) [virtual]
Scrolls the list box so the item at position index in the
list is displayed in the top row of the list box.
See also topItem() and ensureCurrentVisible().
void QListBox::setVariableHeight ( bool enable ) [virtual]
Sets this list box to have variable-height rows if enable
is TRUE, and equal-height rows if enable is FALSE.
When the list box has variable-height rows, 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.
The default is TRUE.
See also setVariableWidth() and variableHeight().
void QListBox::setVariableWidth ( bool enable ) [virtual]
Sets this list box to have variable-width columns if
enable is TRUE, and equal-width columns if enable is
FALSE.
When the list box has variable-width columns, each column
is as wide as the widest item in that column. When it has
item in the list box.
The default is FALSE.
See also setVariableHeight() and variableWidth().
void QListBox::showEvent ( QShowEvent * ) [virtual protected]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QWidget.
QSize QListBox::sizeHint () const [virtual]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QWidget.
void QListBox::sort ( bool ascending = TRUE )
Sorts the item in ascending order, if ascending is TRUE,
or descending otherwise.
To compare the items, the text (QListBoxItem::text()) of
the items is used. The sorting is done using the Quick-
Sort Alogorithm.
void QListBox::takeItem ( const QListBoxItem * item )
Removes item from the listbox and causes an update of the
screen display. The item is not deleted. You should
normally not need to call this function, as
QListBoxItem::~QListBoxItem() calls it. The normal way to
delete an item is delete.
See also QListBox::insertItem().
QString QListBox::text ( int index ) const
Returns the text at position index, or a null string if
there is no text at that position.
See also pixmap().
void QListBox::toggleCurrentItem () [protected]
Toggles the selection status of currentItem() and
repaints, if the listbox is a multi-selection listbox.
See also setMultiSelection().
int QListBox::topItem () const
Returns the index of an item at the top of the screen. If
there are more than one of them, an arbitrary item is
selected and returned.
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.
void QListBox::updateItem ( QListBoxItem * i ) [protected]
Repaints i.
void QListBox::updateItem ( int index ) [protected]
Repaints the item at position index in the list.
bool QListBox::variableHeight () const
Returns TRUE if this list box has variable-height rows,
and FALSE if all the rows have the same height.
See also setVariableHeight() and setVariableWidth().
bool QListBox::variableWidth () const
Returns TRUE if this list box has variable-width columns,
and FALSE if all the columns have the same width.
See also setVariableHeight() and setVariableWidth().
void QListBox::viewportMouseDoubleClickEvent ( QMouseEvent * e )
[virtual protected]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QScrollView.
void QListBox::viewportMouseMoveEvent ( QMouseEvent * e )
[virtual protected]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QScrollView.
void QListBox::viewportMousePressEvent ( QMouseEvent * e )
[virtual protected]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QScrollView.
void QListBox::viewportMouseReleaseEvent ( QMouseEvent * e )
[virtual protected]
Reimplemented for internal reasons; the API is not
affected.
Reimplemented from QScrollView.
void QListBox::viewportPaintEvent ( QPaintEvent * e ) [virtual]
Reimplemented for internal reasons; the API is not
affected.
void QListBox::clearInputString () [protected slot]
For internal use only.
SEE ALSO
http://doc.trolltech.com/qlistbox.html
http://www.trolltech.com/faq/tech.html
COPYRIGHT
Copyright 1992-2001 Trolltech AS,
http://www.trolltech.com. See the license file included
in the distribution for a complete license statement.
AUTHOR
Generated automatically from the source code.
BUGS
If you find a bug in Qt, please report it as described in
http://doc.trolltech.com/bughowto.html. Good bug reports
make our job much simpler. Thank you.
In case of content or formattting problems with this
manual page, please report them to qt-bugs@trolltech.com.
Please include the name of the manual page (qlistbox.3qt)
and the Qt version (2.3.1).
Man(1) output converted with
man2html