The PySide.QtGui.QListWidgetItem class provides an item for use with the PySide.QtGui.QListWidget item view class.
A PySide.QtGui.QListWidgetItem represents a single item in a PySide.QtGui.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 PySide.QtGui.QListView class with a standard model.
List items can be inserted automatically into a list, when they are constructed, by specifying the list widget:
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 PySide.QtGui.QListWidgetItem.text() and an PySide.QtGui.QListWidgetItem.icon() . These are set with the PySide.QtGui.QListWidgetItem.setText() and PySide.QtGui.QListWidgetItem.setIcon() functions. The appearance of the text can be customized with PySide.QtGui.QListWidgetItem.setFont() , PySide.QtGui.QListWidgetItem.setForeground() , and PySide.QtGui.QListWidgetItem.setBackground() . Text in list items can be aligned using the PySide.QtGui.QListWidgetItem.setTextAlignment() function. Tooltips, status tips and “What’s This?” help can be added to list items with PySide.QtGui.QListWidgetItem.setToolTip() , PySide.QtGui.QListWidgetItem.setStatusTip() , and PySide.QtGui.QListWidgetItem.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 PySide.QtGui.QListWidgetItem.setFlags() with the appropriate value (see Qt.ItemFlags ). Checkable items can be checked, unchecked and partially checked with the PySide.QtGui.QListWidgetItem.setCheckState() function. The corresponding PySide.QtGui.QListWidgetItem.checkState() function indicates the item’s current check state.
The PySide.QtGui.QListWidgetItem.isHidden() function can be used to determine whether the item is hidden. To hide an item, use PySide.QtGui.QListWidgetItem.setHidden() .
When subclassing PySide.QtGui.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.
See also
PySide.QtGui.QListWidget Model/View Programming PySide.QtGui.QTreeWidgetItem PySide.QtGui.QTableWidgetItem
Parameters: |
|
---|
Constructs an empty list widget item of the specified type with the given parent . If parent is not specified, the item will need to be inserted into a list widget with QListWidget.insertItem() .
This constructor inserts the item into the model of the parent that is passed to the constructor. If the model is sorted then the behavior of the insert is undetermined since the model will call the '<' operator method on the item which, at this point, is not yet constructed. To avoid the undetermined behavior, we recommend not to specify the parent and use QListWidget.insertItem() instead.
See also
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() .
This constructor inserts the item into the model of the parent that is passed to the constructor. If the model is sorted then the behavior of the insert is undetermined since the model will call the '<' operator method on the item which, at this point, is not yet constructed. To avoid the undetermined behavior, we recommend not to specify the parent and use QListWidget.insertItem() instead.
See also
Constructs a copy of other . Note that PySide.QtGui.QListWidgetItem.type() and PySide.QtGui.QListWidgetItem.listWidget() are not copied.
This function is useful when reimplementing PySide.QtGui.QListWidgetItem.clone() .
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() .
This constructor inserts the item into the model of the parent that is passed to the constructor. If the model is sorted then the behavior of the insert is undetermined since the model will call the '<' operator method on the item which, at this point, is not yet constructed. To avoid the undetermined behavior, we recommend not to specify the parent and use QListWidget.insertItem() instead.
See also
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 UserType are reserved by Qt. |
You can define new user types in PySide.QtGui.QListWidgetItem subclasses to ensure that custom items are treated specially.
See also
Return type: | PySide.QtGui.QBrush |
---|
Returns the brush used to display the list item’s background.
Return type: | PySide.QtCore.Qt.CheckState |
---|
Returns the checked state of the list item (see Qt.CheckState ).
Return type: | PySide.QtGui.QListWidgetItem |
---|
Creates an exact copy of the item.
Parameters: | role – PySide.QtCore.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
Qt.ItemDataRole PySide.QtGui.QListWidgetItem.setData()
Return type: | PySide.QtCore.Qt.ItemFlags |
---|
Returns the item flags for this item (see Qt.ItemFlags ).
Return type: | PySide.QtGui.QFont |
---|
Returns the font used to display this list item’s text.
Return type: | PySide.QtGui.QBrush |
---|
Returns the brush used to display the list item’s foreground (e.g. text).
Return type: | PySide.QtGui.QIcon |
---|
Returns the list item’s icon.
Return type: | PySide.QtCore.bool |
---|
Returns true if the item is hidden; otherwise returns false.
Return type: | PySide.QtCore.bool |
---|
Returns true if the item is selected; otherwise returns false.
Return type: | PySide.QtGui.QListWidget |
---|
Returns the list widget containing the item.
Parameters: | other – PySide.QtGui.QListWidgetItem |
---|---|
Return type: | PySide.QtCore.bool |
Returns true if this item’s text is less then other item’s text; otherwise returns false.
Parameters: | in – PySide.QtCore.QDataStream |
---|
Reads the item from stream in .
See also
Parameters: | brush – PySide.QtGui.QBrush |
---|
Sets the background brush of the list item to the given brush .
Parameters: | state – PySide.QtCore.Qt.CheckState |
---|
Parameters: |
|
---|
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.
See also
Qt.ItemDataRole PySide.QtGui.QListWidgetItem.data()
Parameters: | flags – PySide.QtCore.Qt.ItemFlags |
---|
Parameters: | font – PySide.QtGui.QFont |
---|
Sets the font used when painting the item to the given font .
See also
Parameters: | brush – PySide.QtGui.QBrush |
---|
Sets the foreground brush of the list item to the given brush .
Parameters: | hide – PySide.QtCore.bool |
---|
Hides the item if hide is true; otherwise shows the item.
Parameters: | icon – PySide.QtGui.QIcon |
---|
Sets the icon for the list item to the given icon .
Parameters: | select – PySide.QtCore.bool |
---|
Sets the selected state of the item to select .
Parameters: | size – PySide.QtCore.QSize |
---|
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.
Parameters: | statusTip – unicode |
---|
Sets the status tip for the list item to the text specified by statusTip . PySide.QtGui.QListWidget mouseTracking needs to be enabled for this feature to work.
Parameters: | text – unicode |
---|
Sets the text for the list widget item’s to the given text .
See also
Parameters: | alignment – PySide.QtCore.int |
---|
Sets the list item’s text alignment to alignment .
See also
PySide.QtGui.QListWidgetItem.textAlignment() Qt.AlignmentFlag
Parameters: | toolTip – unicode |
---|
Sets the tooltip for the list item to the text specified by toolTip .
Parameters: | whatsThis – unicode |
---|
Sets the “What’s This?” help for the list item to the text specified by whatsThis .
Return type: | PySide.QtCore.QSize |
---|
Returns the size hint set for the list item.
Return type: | unicode |
---|
Returns the list item’s status tip.
Return type: | unicode |
---|
Returns the list item’s text.
Return type: | PySide.QtCore.int |
---|
Returns the text alignment for the list item.
See also
PySide.QtGui.QListWidgetItem.setTextAlignment() Qt.AlignmentFlag
Return type: | unicode |
---|
Returns the list item’s tooltip.
Return type: | PySide.QtCore.int |
---|
Returns the type passed to the PySide.QtGui.QListWidgetItem constructor.
Return type: | unicode |
---|
Returns the list item’s “What’s This?” help text.
Parameters: | out – PySide.QtCore.QDataStream |
---|
Writes the item to stream out .
See also