Qt Toolkit - QListBoxItem Class

| Classes - Annotated - Tree - Functions - Home - Structure

# QListBoxItem Class Reference

This is the base class of all list box items. More...

`#include <qlistbox.h>`

Inherited by QListBoxPixmap and QListBoxText.

List of all member functions.

## Public Members

- QListBoxItem ( QListBox * listbox = 0 )
- QListBoxItem ( QListBox * listbox, QListBoxItem * after )
- virtual ~QListBoxItem ()
- virtual QString text () const
- virtual const QPixmap* pixmap () const
- virtual int height ( const QListBox * ) const
- virtual int width ( const QListBox * ) const
- bool selected () const
- bool current () const
- QListBox* listBox () const
- void setSelectable ( bool b )
- bool isSelectable () const
- QListBoxItem* next () const
- QListBoxItem* prev () const

## Protected Members

- virtual void paint ( QPainter * )
- virtual void setText ( const QString & text )
- void setCustomHighlighting ( bool )

## Detailed Description

This is the base class of all list box items.

This class is the abstract base class of all list box items. If you need to insert customized items into a QListBox, you must inherit this class and reimplement paint(), height() and width().

See also QListBox.

## Member Function Documentation

### QListBoxItem::QListBoxItem ( QListBox * listbox = 0 )

Constructs an empty list box item in the listbox listbox

### QListBoxItem::QListBoxItem ( QListBox * listbox, QListBoxItem * after )

Constructs an empty list box item in the listbox listbox and inserts it after the item after.

### QListBoxItem::~QListBoxItem () `[virtual]`

Destroys the list box item.

### bool QListBoxItem::current () const

Returns TRUE if the item is the current item, else FALSE.

See also QListBox::currentItem(), QListBox::item() and selected().

### int QListBoxItem::height ( const QListBox * lb ) const `[virtual]`

Implement this function to return the height of your item. The lb parameter is the same as listBox() and is provided for convenience and compatibility.

See also paint() and width().

Reimplemented in QListBoxPixmap and QListBoxText.

### bool QListBoxItem::isSelectable () const

Returns if this item is selectable or not.

See also setSelectable().

### QListBox * QListBoxItem::listBox () const

Returns a pointer to the listbox containing this item.

### QListBoxItem * QListBoxItem::next () const

Returns the item which comes after this in the listbox. If this is the last item, 0 is returned.

### void QListBoxItem::paint ( QPainter * p ) `[virtual protected]`

Implement this function to draw your item.

See also height() and width().

Reimplemented in QListBoxPixmap and QListBoxText.

### const QPixmap * QListBoxItem::pixmap () const `[virtual]`

Returns the pixmap connected with the item, if any.

The default implementation of this function returns a null pointer.

Reimplemented in QListBoxPixmap.

### QListBoxItem * QListBoxItem::prev () const

Returns the item which comes before this in the listbox. If this is the first item, 0 is returned.

### bool QListBoxItem::selected () const

Returns TRUE if the item is selected, else FALSE.

See also QListBox::isSelected() and current().

### void QListBoxItem::setCustomHighlighting ( bool b ) `[protected]`

Defines whether the list box items is responsible to draw itself in a highlighted state when being selected.

If b is FALSE (the default), then the listbox will draw some default highlight indicator before calling paint().

See also selected() and paint().

### void QListBoxItem::setSelectable ( bool b )

Specifies if this item may be selected by the user or not.

See also isSelectable().

### void QListBoxItem::setText ( const QString & text ) `[virtual protected]`

Sets the text of the widget, which is used for sorting too. The text is not shown unless explicitly drawn in paint().

See also text().

### QString QListBoxItem::text () const `[virtual]`

Returns the text of the item, which is used for sorting too.

See also setText().

### int QListBoxItem::width ( const QListBox * lb ) const `[virtual]`

Implement this function to return the width of your item. The lb parameter is the same as listBox() and is provided for convenience and compatibility.

See also paint() and height().

Reimplemented in QListBoxPixmap and QListBoxText.

Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):

This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.