Skip to content

PythonQt.QtGui.QListWidgetItem

QListWidgetItem

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

A QListWidgetItem represents a single item in a QListWidget. Each item can hold several pieces of information, and will display them 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 inserted automatically into a list, when they are constructed, by specifying the list widget:

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

Alternatively, list items can also be created without a parent widget, and later inserted into a list using 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 drag and drop operations.

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 the item's current check state.

The isHidden() function can be used to determine whether the item is hidden. To hide an item, use setHidden().

Subclassing

When subclassing QListWidgetItem to provide custom items, it is possible to define new types for them enabling them to be distinguished from standard items. For subclasses that require this feature, ensure that you call the base class constructor with a new type value equal to or greater than UserType, within your constructor.

Source: https://doc.qt.io/archives/qt-5.15/qlistwidgetitem.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
ItemType attribute type Convert a number or string to an integer, or return 0 if no arguments are given.
Type attribute Any (shared captured text)
UserType attribute Any (shared captured text)
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
background function (self) -> Any X.background() -> PythonQt.QtGui.QBrush
checkState function (self) -> Any Returns the checked state of the list item (see [Qt::CheckState](https://doc.qt.io/archives/qt-5.15/qt.html#CheckState-enum)).
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
clone function (self) -> Any X.clone() -> PythonQt.QtGui.QListWidgetItem
data function (self, role: int) -> Any X.data(role) -> object
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
flags function (self) -> Any Returns the item flags for this item (see [Qt::ItemFlags](https://doc.qt.io/archives/qt-5.15/qt.html#ItemFlag-enum)).
font function (self) -> Any X.font() -> PythonQt.QtGui.QFont
foreground function (self) -> Any X.foreground() -> PythonQt.QtGui.QBrush
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
icon function (self) -> Any X.icon() -> PythonQt.QtGui.QIcon
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
isHidden function (self) -> bool X.isHidden() -> bool
isSelected function (self) -> bool X.isSelected() -> bool
listWidget function (self) -> Any X.listWidget() -> PythonQt.QtGui.QListWidget
read function (self, *args: Any, **kwargs: Any) -> None Reads the item from stream in.
readFrom function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
setBackground function (self, brush: Any) -> None Sets the background brush of the list item to the given brush.
setCheckState function (self, state: Any) -> None Sets the check state of the list item to state.
setData function (self, role: int, value: Any) -> None X.setData(role, value)
setFlags function (self, arg0: flags) -> None Sets the item flags for the list item to flags.
setFont function (self, font: Any) -> None Sets the font used when painting the item to the given font.
setForeground function (self, brush: Any) -> None Sets the foreground brush of the list item to the given brush.
setHidden function (self, hide: bool) -> None Hides the item if hide is true; otherwise shows the item.
setIcon function (self, icon: Any) -> None Sets the icon for the list item to the given icon.
setSelected function (self, select: bool) -> None Sets the selected state of the item to select.
setSizeHint function (self, size: Any) -> None Sets the size hint for the list item to be size.
setStatusTip function (self, statusTip: str) -> None Sets the status tip for the list item to the text specified by statusTip.
setText function (self, text: str) -> None Sets the text for the list widget item's to the given text.
setTextAlignment function (self, alignment: int) -> None Sets the list item's text alignment to alignment.
setToolTip function (self, toolTip: str) -> None Sets the tooltip for the list item to the text specified by toolTip.
setWhatsThis function (self, whatsThis: str) -> None Sets the "What's This?" help for the list item to the text specified by whatsThis.
sizeHint function (self) -> Any X.sizeHint() -> PythonQt.QtCore.QSize
statusTip function (self) -> str X.statusTip() -> str
text function (self) -> str X.text() -> str
textAlignment function (self) -> int X.textAlignment() -> int
toolTip function (self) -> str X.toolTip() -> str
type function (self) -> int X.type() -> int
whatsThis function (self) -> str X.whatsThis() -> str
write function (self, out: Any) -> None Writes the item to stream out.
writeTo function (self, out: Any) -> Any (shared captured text)