Home · All Classes · Modules

QListWidgetItem Class Reference
[QtGui module]

The QListWidgetItem class provides an item for use with the QListWidget item view class. More...

Methods

Special Methods

Static Members


Detailed Description

The QListWidgetItem class provides an item for use with the QListWidget item view class.

QListWidgetItem is used to represent items in a list provided by the QListWidget class. Each item can hold several pieces of information, and will display these appropriately.

The item view convenience classes use a classic item-based interface rather than a pure model/view approach. For a more flexible list view widget, consider using the QListView class with a standard model.

List items can be automatically inserted into a list when they are constructed by specifying the list widget:

        new QListWidgetItem(tr("Hazel"), listWidget);

They can also be created without a parent widget, and later inserted into a list (see QListWidget.insertItem()).

List items are typically used to display text() and an icon(). These are set with the setText() and setIcon() functions. The appearance of the text can be customized with setFont(), setTextColor(), and setBackgroundColor(). List items can be aligned using the setAlignment() function. Tooltips, status tips and "What's This?" help can be added to list items with setToolTip(), setStatusTip(), and setWhatsThis().

By default, items are enabled, selectable, checkable, and can be the source of a drag and drop operation. Each item's flags can be changed by calling setFlags() with the appropriate value (see Qt.ItemFlags). Checkable items can be checked and unchecked with the setChecked() function. The corresponding checked() function indicates whether the item is currently checked.

The isItemHidden() function can be used to determine whether the item is hidden. Items can be hidden with setItemHidden().

See also QListWidget, Model/View Programming, QTreeWidgetItem, and QTableWidgetItem.


Method Documentation

QListWidgetItem.__init__ (self, QListWidget view = None, int type = QListWidgetItem.Type)

The view argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs an empty list widget item of the specified type with the given parent. If the parent is not specified, the item will need to be inserted into a list widget with QListWidget.insertItem().

See also type().

QListWidgetItem.__init__ (self, QString text, QListWidget view = None, int type = QListWidgetItem.Type)

The view argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs an empty list widget item of the specified type with the given text and parent. If the parent is not specified, the item will need to be inserted into a list widget with QListWidget.insertItem().

See also type().

QListWidgetItem.__init__ (self, QIcon icon, QString text, QListWidget view = None, int type = QListWidgetItem.Type)

The view argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs an empty list widget item of the specified type with the given icon, text and parent. If the parent is not specified, the item will need to be inserted into a list widget with QListWidget.insertItem().

See also type().

QListWidgetItem.__init__ (self, QListWidgetItem other)

Constructs a copy of other. Note that type() and listWidget() are not copied.

This function is useful when reimplementing clone().

This function was introduced in Qt 4.1.

See also data() and flags().

QColor QListWidgetItem.backgroundColor (self)

Returns the color used to display the list item's background.

See also setBackgroundColor() and textColor().

Qt.CheckState QListWidgetItem.checkState (self)

Returns the checked state of the list item (see Qt.CheckState.

See also setCheckState() and flags().

QListWidgetItem QListWidgetItem.clone (self)

Creates an exact copy of the item.

QVariant QListWidgetItem.data (self, int role)

This function returns the item's data for a given role (see {Qt.ItemDataRole}). Reimplement this function if you need extra roles or special behavior for certain roles.

See also setData().

Qt.ItemFlags QListWidgetItem.flags (self)

Returns the item flags for this item (see {Qt.ItemFlags}).

See also setFlags().

QFont QListWidgetItem.font (self)

Returns the font used to display this list item's text.

See also setFont().

QIcon QListWidgetItem.icon (self)

Returns the list item's icon.

See also setIcon() and iconSize.

QListWidget QListWidgetItem.listWidget (self)

Returns the list widget that contains the item.

QListWidgetItem.read (self, QDataStream in)

Reads the item from stream in.

See also write().

QListWidgetItem.setBackgroundColor (self, QColor color)

Sets the background color of the list item to the given color.

See also backgroundColor() and setTextColor().

QListWidgetItem.setCheckState (self, Qt.CheckState state)

Sets the check state of the list item to state.

See also checkState().

QListWidgetItem.setData (self, int role, QVariant value)

This function sets the data for a given role to the given value (see Qt.ItemDataRole). Reimplement this function if you need extra roles or special behavior for certain roles.

See also Qt.ItemDataRole, data(), and itemData().

QListWidgetItem.setFlags (self, Qt.ItemFlags aflags)

Sets the item flags for the list item to flags (see Qt.ItemFlags).

See also flags().

QListWidgetItem.setFont (self, QFont afont)

Sets the font used when painting the item to the given font.

See also font().

QListWidgetItem.setIcon (self, QIcon aicon)

Sets the icon for the list item to the given icon.

See also icon(), text(), and iconSize.

QListWidgetItem.setSizeHint (self, QSize size)

Sets the size hint for the list item to be size. If no size hint is set, the item delegate will compute the size hint based on the item data.

This function was introduced in Qt 4.1.

See also sizeHint().

QListWidgetItem.setStatusTip (self, QString astatusTip)

Sets the status tip for the list item to the text specified by statusTip.

See also statusTip(), setToolTip(), and setWhatsThis().

QListWidgetItem.setText (self, QString atext)

Sets the text for the list widget item's to the given text.

See also text().

QListWidgetItem.setTextAlignment (self, int alignment)

Sets the list item's text alignment to alignment (see Qt.AlignmentFlag).

See also textAlignment().

QListWidgetItem.setTextColor (self, QColor color)

Sets the text color for the list item to the given color.

See also textColor() and setBackgroundColor().

QListWidgetItem.setToolTip (self, QString atoolTip)

Sets the tooltip for the list item to the text specified by toolTip.

See also toolTip(), setStatusTip(), and setWhatsThis().

QListWidgetItem.setWhatsThis (self, QString awhatsThis)

Sets the "What's This?" help for the list item to the text specified by whatsThis.

See also whatsThis(), setStatusTip(), and setToolTip().

QSize QListWidgetItem.sizeHint (self)

Returns the size hint set for the list item.

This function was introduced in Qt 4.1.

See also setSizeHint().

QString QListWidgetItem.statusTip (self)

Returns the list item's status tip.

See also setStatusTip().

QString QListWidgetItem.text (self)

Returns the list item's text.

See also setText().

int QListWidgetItem.textAlignment (self)

Returns the text alignment for the list item (see Qt.AlignmentFlag).

See also setTextAlignment().

QColor QListWidgetItem.textColor (self)

Returns the used to display the list item's text.

See also setTextColor() and backgroundColor().

QString QListWidgetItem.toolTip (self)

Returns the list item's tooltip.

See also setToolTip(), statusTip(), and whatsThis().

int QListWidgetItem.type (self)

Returns the type passed to the QListWidgetItem constructor.

QString QListWidgetItem.whatsThis (self)

Returns the list item's "What's This?" help text.

See also setWhatsThis(), statusTip(), and toolTip().

QListWidgetItem.write (self, QDataStream out)

Writes the item to stream out.

See also read().

bool QListWidgetItem.__lt__ (self, QListWidgetItem other)


Member Documentation

int Type

This member should be treated as a constant.

The default type for list widget items.

See also UserType and type().

int UserType

This member should be treated as a constant.

The minimum value for custom types. Values below UserType are reserved by Qt.

See also Type and type().


PyQt 4.0.1 for X11Copyright © Riverbank Computing Ltd and Trolltech AS 2006Qt 4.1.4