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

Synopsis¶
Functions¶
def
background
()def
checkState
()def
flags
()def
font
()def
foreground
()def
icon
()def
isHidden
()def
isSelected
()def
listWidget
()def
setBackground
(brush)def
setCheckState
(state)def
setFlags
(flags)def
setFont
(font)def
setForeground
(brush)def
setHidden
(hide)def
setIcon
(icon)def
setSelected
(select)def
setSizeHint
(size)def
setStatusTip
(statusTip)def
setText
(text)def
setTextAlignment
(alignment)def
setToolTip
(toolTip)def
setWhatsThis
(whatsThis)def
sizeHint
()def
statusTip
()def
text
()def
textAlignment
()def
toolTip
()def
type
()def
whatsThis
()
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 insertItem()
.
List items are typically used to display and an . These are set with the and functions. The appearance of the text can be customized with , , and . Text in list items can be aligned using the function. Tooltips, status tips and “What’s This?” help can be added to list items with , , and .
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 with the appropriate value (see ItemFlags
). Checkable items can be checked, unchecked and partially checked with the function. The corresponding function indicates the item’s current check state.
The function can be used to determine whether the item is hidden. To hide an item, use .
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.
-
class
PySide6.QtWidgets.
QListWidgetItem
([listview=None[, type=Type]])¶ PySide6.QtWidgets.QListWidgetItem(icon, text[, listview=None[, type=Type]])
PySide6.QtWidgets.QListWidgetItem(other)
PySide6.QtWidgets.QListWidgetItem(text[, listview=None[, type=Type]])
- Parameters
icon –
PySide6.QtGui.QIcon
text – str
listview –
PySide6.QtWidgets.QListWidget
type – int
Constructs a copy of other
. Note that and are not copied.
This function is useful when reimplementing clone()
.
-
PySide6.QtWidgets.QListWidgetItem.
ItemType
¶
This enum describes the types that are used to describe list widget items.
Constant
Description
QListWidgetItem.Type
The default type for list widget items.
QListWidgetItem.UserType
The minimum value for custom types. Values below are reserved by Qt.
You can define new user types in QListWidgetItem
subclasses to ensure that custom items are treated specially.
See also
-
PySide6.QtWidgets.QListWidgetItem.
background
()¶ - Return type
-
PySide6.QtWidgets.QListWidgetItem.
checkState
()¶ - Return type
-
PySide6.QtWidgets.QListWidgetItem.
clone
()¶ - Return type
Creates an exact copy of the item.
-
PySide6.QtWidgets.QListWidgetItem.
data
(role)¶ - Parameters
role – int
- Return type
object
Returns the item’s data for a given role
. Reimplement this function if you need extra roles or special behavior for certain roles.
See also
ItemDataRole
setData()
-
PySide6.QtWidgets.QListWidgetItem.
flags
()¶ - Return type
ItemFlags
-
PySide6.QtWidgets.QListWidgetItem.
font
()¶ - Return type
-
PySide6.QtWidgets.QListWidgetItem.
foreground
()¶ - Return type
-
PySide6.QtWidgets.QListWidgetItem.
icon
()¶ - Return type
-
PySide6.QtWidgets.QListWidgetItem.
isHidden
()¶ - Return type
bool
-
PySide6.QtWidgets.QListWidgetItem.
isSelected
()¶ - Return type
bool
-
PySide6.QtWidgets.QListWidgetItem.
listWidget
()¶ - Return type
-
PySide6.QtWidgets.QListWidgetItem.
__lt__
(other)¶ - Parameters
- Return type
bool
-
PySide6.QtWidgets.QListWidgetItem.
read
(in)¶ - Parameters
Reads the item from stream in
.
See also
-
PySide6.QtWidgets.QListWidgetItem.
setBackground
(brush)¶ - Parameters
brush –
PySide6.QtGui.QBrush
-
PySide6.QtWidgets.QListWidgetItem.
setCheckState
(state)¶ - Parameters
state –
CheckState
-
PySide6.QtWidgets.QListWidgetItem.
setData
(role, value)¶ - Parameters
role – int
value – object
Sets the data for a given role
to the given value
. Reimplement this function if you need extra roles or special behavior for certain roles.
Note
The default implementation treats EditRole
and DisplayRole
as referring to the same data.
See also
ItemDataRole
data()
-
PySide6.QtWidgets.QListWidgetItem.
setFlags
(flags)¶ - Parameters
flags –
ItemFlags
-
PySide6.QtWidgets.QListWidgetItem.
setFont
(font)¶ - Parameters
font –
PySide6.QtGui.QFont
-
PySide6.QtWidgets.QListWidgetItem.
setForeground
(brush)¶ - Parameters
brush –
PySide6.QtGui.QBrush
-
PySide6.QtWidgets.QListWidgetItem.
setHidden
(hide)¶ - Parameters
hide – bool
-
PySide6.QtWidgets.QListWidgetItem.
setIcon
(icon)¶ - Parameters
icon –
PySide6.QtGui.QIcon
-
PySide6.QtWidgets.QListWidgetItem.
setSelected
(select)¶ - Parameters
select – bool
-
PySide6.QtWidgets.QListWidgetItem.
setSizeHint
(size)¶ - Parameters
size –
PySide6.QtCore.QSize
-
PySide6.QtWidgets.QListWidgetItem.
setStatusTip
(statusTip)¶ - Parameters
statusTip – str
-
PySide6.QtWidgets.QListWidgetItem.
setText
(text)¶ - Parameters
text – str
-
PySide6.QtWidgets.QListWidgetItem.
setTextAlignment
(alignment)¶ - Parameters
alignment – int
-
PySide6.QtWidgets.QListWidgetItem.
setToolTip
(toolTip)¶ - Parameters
toolTip – str
-
PySide6.QtWidgets.QListWidgetItem.
setWhatsThis
(whatsThis)¶ - Parameters
whatsThis – str
-
PySide6.QtWidgets.QListWidgetItem.
sizeHint
()¶ - Return type
-
PySide6.QtWidgets.QListWidgetItem.
statusTip
()¶ - Return type
str
-
PySide6.QtWidgets.QListWidgetItem.
text
()¶ - Return type
str
-
PySide6.QtWidgets.QListWidgetItem.
textAlignment
()¶ - Return type
int
-
PySide6.QtWidgets.QListWidgetItem.
toolTip
()¶ - Return type
str
-
PySide6.QtWidgets.QListWidgetItem.
type
()¶ - Return type
int
-
PySide6.QtWidgets.QListWidgetItem.
whatsThis
()¶ - Return type
str
-
PySide6.QtWidgets.QListWidgetItem.
write
(out)¶ - Parameters
Writes the item to stream out
.
See also
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.