![]() |
Home · Overviews · Examples |
The QListWidgetItem class provides an item for use with the QListWidget item view class. More...
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, setForeground, and setBackground. Text in list items can be aligned using the setTextAlignment 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, unchecked and partially checked with the setCheckState function. The corresponding checkState function indicates what check state the item currently has.
The isHidden function can be used to determine whether the item is hidden. Items can be hidden with setHidden.
When subclassing QListWidgetItem to provide custom items, it is possible to define new types for them so that they can be distinguished from standard items. The constructors for subclasses that require this feature need to call the base class constructor with a new type value equal to or greater than UserType.
See also QListWidget, Model/View Programming, QTreeWidgetItem, and QTableWidgetItem.
Copyright © 2007 Trolltech | Trademarks | Qt Jambi 4.3.2_01 |