Skip to content

PythonQt.Qt.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. (shared captured text)
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 (shared captured text)
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)). (shared captured text)
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 (shared captured text)
data function (self, role: int) -> Any X.data(role) -> object (shared captured text)
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)). (shared captured text)
font function (self) -> Any X.font() -> PythonQt.QtGui.QFont (shared captured text)
foreground function (self) -> Any X.foreground() -> PythonQt.QtGui.QBrush (shared captured text)
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 (shared captured text)
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 (shared captured text)
isSelected function (self) -> bool X.isSelected() -> bool (shared captured text)
listWidget function (self) -> Any X.listWidget() -> PythonQt.QtGui.QListWidget (shared captured text)
read function (self, *args: Any, **kwargs: Any) -> None Reads the item from stream in. (shared captured text)
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. (shared captured text)
setCheckState function (self, state: Any) -> None Sets the check state of the list item to state. (shared captured text)
setData function (self, role: int, value: Any) -> None X.setData(role, value) (shared captured text)
setFlags function (self, arg0: flags) -> None Sets the item flags for the list item to flags. (shared captured text)
setFont function (self, font: Any) -> None Sets the font used when painting the item to the given font. (shared captured text)
setForeground function (self, brush: Any) -> None Sets the foreground brush of the list item to the given brush. (shared captured text)
setHidden function (self, hide: bool) -> None Hides the item if hide is true; otherwise shows the item. (shared captured text)
setIcon function (self, icon: Any) -> None Sets the icon for the list item to the given icon. (shared captured text)
setSelected function (self, select: bool) -> None Sets the selected state of the item to select. (shared captured text)
setSizeHint function (self, size: Any) -> None Sets the size hint for the list item to be size. (shared captured text)
setStatusTip function (self, statusTip: str) -> None Sets the status tip for the list item to the text specified by statusTip. (shared captured text)
setText function (self, text: str) -> None Sets the text for the list widget item's to the given text. (shared captured text)
setTextAlignment function (self, alignment: int) -> None Sets the list item's text alignment to alignment. (shared captured text)
setToolTip function (self, toolTip: str) -> None Sets the tooltip for the list item to the text specified by toolTip. (shared captured text)
setWhatsThis function (self, whatsThis: str) -> None Sets the "What's This?" help for the list item to the text specified by whatsThis. (shared captured text)
sizeHint function (self) -> Any X.sizeHint() -> PythonQt.QtCore.QSize (shared captured text)
statusTip function (self) -> str X.statusTip() -> str (shared captured text)
text function (self) -> str X.text() -> str (shared captured text)
textAlignment function (self) -> int X.textAlignment() -> int (shared captured text)
toolTip function (self) -> str X.toolTip() -> str (shared captured text)
type function (self) -> int X.type() -> int (shared captured text)
whatsThis function (self) -> str X.whatsThis() -> str (shared captured text)
write function (self, out: Any) -> None Writes the item to stream out. (shared captured text)
writeTo function (self, out: Any) -> Any (shared captured text)