Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QListBoxItem Class Reference

The QListBoxItem class is the base class of all list box items. More...

    #include <QListBoxItem>

This class is part of the Qt 3 compatibility library. It is provided to keep old source code working. We strongly advise against using it in new code.

Inherited by QListBoxText and QListBoxPixmap.

- List of all members, including inherited members

### Public Functions

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

### Protected Functions

- virtual void paint ( QPainter * p ) = 0
- void setCustomHighlighting ( bool b )
- virtual void setText ( const QString & text )

## Detailed Description

The QListBoxItem class is the base class of all list box items.

This class is an abstract base class used for 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 list box listbox.

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

Constructs an empty list box item in the list box listbox and inserts it after the item after or at the beginning if after is 0.

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

Destroys the list box item.

### bool QListBoxItem::current () const

Use isCurrent() instead.

### 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.

The default implementation returns QApplication::globalStrut()'s height.

See also paint() and width().

### bool QListBoxItem::isCurrent () const

Returns true if the item is the current item; otherwise returns false.

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

### bool QListBoxItem::isSelectable () const

Returns true if this item is selectable (the default); otherwise returns false.

See also setSelectable().

### bool QListBoxItem::isSelected () const

Returns true if the item is selected; otherwise returns false.

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

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

Returns a pointer to the list box containing this item.

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

Returns the item that comes after this in the list box. If this is the last item, 0 is returned.

See also prev().

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

Implement this function to draw your item. The painter, p, is already open for painting.

See also height() and width().

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

Returns the pixmap associated with the item, or 0 if there isn't one.

The default implementation returns 0.

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

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

See also next().

### int QListBoxItem::rtti () const `[virtual]`

Returns 0.

Make your derived classes return their own values for rtti(), and you can distinguish between listbox items. You should use values greater than 1000 preferably a large random number, to allow for extensions to this class.

### bool QListBoxItem::selected () const

Use isSelected() instead.

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

Defines whether the list box item is responsible for drawing itself in a highlighted state when being selected.

If b is false (the default), the list box will draw some default highlight indicator before calling paint().

See also isSelected() and paint().

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

If b is true (the default) then this item can be selected by the user; otherwise this item cannot be selected by the user.

See also isSelectable().

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

Sets the text of the QListBoxItem to text. This text is also used for sorting. The text is not shown unless explicitly drawn in paint().

See also text().

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

Returns the text of the item. This text is also used for sorting.

See also setText().

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

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

The default implementation returns QApplication::globalStrut()'s width.

See also paint() and height().