Classes - Annotated - Tree - Functions - Home - Structure

QListBoxItem Class Reference

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

#include <qlistbox.h>

Inherited by QListBoxText and QListBoxPixmap.

List of all member functions.

Public Members

Protected Members


Detailed Description

The QListBoxItem class 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 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.

QListBoxItem::~QListBoxItem () [virtual]

Destroys the list box item.

bool QListBoxItem::current () const

Returns TRUE if the item is the current item, otherwise 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 QListBoxText and QListBoxPixmap.

bool QListBoxItem::isSelectable () const

Returns if this item is selectable or not.

See also setSelectable().

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, a null pointer is returned.

See also prev().

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

Implement this function to draw your item. You will need to pass the QPainter that will draw this item as the parameter p.

See also height() and width().

Example: listboxcombo/listboxcombo.cpp.

Reimplemented in QListBoxText and QListBoxPixmap.

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.

Example: listboxcombo/listboxcombo.cpp.

Reimplemented in QListBoxPixmap.

QListBoxItem * QListBoxItem::prev () const

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

See also next().

int QListBoxItem::rtti () const [virtual]

Returns 0.

Although often frowned upon by purists, Run Time Type Identification is very useful in this case, as it allows a QListBox to be an efficient indexed storage mechanism.

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

Returns TRUE if the item is selected, otherwise FALSE.

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

Example: listboxcombo/listboxcombo.cpp.

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

Defines whether the list box item is responsible to draw 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 selected() and paint().

void QListBoxItem::setSelectable ( bool b )

If b is TRUE then this item can be selected by the user. If b is FALSE then 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, which 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, which is also used for sorting.

See also setText().

Example: listboxcombo/listboxcombo.cpp.

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 QListBoxText and QListBoxPixmap.


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.


Copyright © 2001 TrolltechTrademarks
Qt version 3.0.0-beta1-beta1