QListWidgetItemclass provides an item for use with theQListWidget项视图类。 更多 …
def
background
()
def
backgroundColor
()
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
setTextColor
(color)
def
setToolTip
(toolTip)
def
setWhatsThis
(whatsThis)
def
sizeHint
()
def
statusTip
()
def
text
()
def
textAlignment
()
def
textColor
()
def
toolTip
()
def
type
()
def
whatsThis
()
A
QListWidgetItemrepresents a single item in aQListWidget. 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类采用标准模型。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
text()和icon(). These are set with thesetText()andsetIcon()functions. The appearance of the text can be customized withsetFont(),setForeground(),和setBackground(). Text in list items can be aligned using thesetTextAlignment()function. Tooltips, status tips and “What’s This?” help can be added to list items withsetToolTip(),setStatusTip(),和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 (seeItemFlags). Checkable items can be checked, unchecked and partially checked with thesetCheckState()function. The correspondingcheckState()function indicates the item’s current check state.
isHidden()function can be used to determine whether the item is hidden. To hide an item, usesetHidden().
当子类化
QListWidgetItemto 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 thanUserType, within your 构造函数。
QListWidgetItem
(
[
listview=None
[
,
type=Type
]
]
)
¶
QListWidgetItem(icon, text[, listview=None[, type=Type]])
QListWidgetItem(other)
QListWidgetItem(text[, listview=None[, type=Type]])
- param listview
- param type
int- param icon
QIcon- param other
- param text
unicode
Constructs an empty list widget item of the specified
type
采用给定
parent
。若
parent
is not specified, the item will need to be inserted into a list widget with
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
insertItem()
代替。
另请参阅
Constructs an empty list widget item of the specified
type
采用给定
icon
,
text
and
parent
. If the parent is not specified, the item will need to be inserted into a list widget with
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
insertItem()
代替。
另请参阅
构造副本为
other
。注意
type()
and
listWidget()
are not copied.
此函数是有用的,当重实现
clone()
.
Constructs an empty list widget item of the specified
type
采用给定
text
and
parent
. If the parent is not specified, the item will need to be inserted into a list widget with
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
insertItem()
代替。
另请参阅
PySide2.QtWidgets.QListWidgetItem.
ItemType
¶
This enum describes the types that are used to describe list widget items.
|
常量 |
描述 |
|---|---|
|
QListWidgetItem.Type |
The default type for list widget items. |
|
QListWidgetItem.UserType |
The minimum value for custom types. Values below are reserved by Qt. |
可以定义新用户类型在
QListWidgetItem
subclasses to ensure that custom items are treated specially.
另请参阅
PySide2.QtWidgets.QListWidgetItem.
background
(
)
¶
QBrush
Returns the brush used to display the list item’s background.
PySide2.QtWidgets.QListWidgetItem.
backgroundColor
(
)
¶
QColor
注意
此函数被弃用。
This function is deprecated. Use
background()
代替。
另请参阅
PySide2.QtWidgets.QListWidgetItem.
checkState
(
)
¶
CheckState
Returns the checked state of the list item (see
CheckState
).
另请参阅
PySide2.QtWidgets.QListWidgetItem.
clone
(
)
¶
Creates an exact copy of the item.
PySide2.QtWidgets.QListWidgetItem.
data
(
role
)
¶
role
–
int
object
Returns the item’s data for a given
role
. Reimplement this function if you need extra roles or special behavior for certain roles.
另请参阅
ItemDataRole
setData()
PySide2.QtWidgets.QListWidgetItem.
flags
(
)
¶
ItemFlags
Returns the item flags for this item (see
ItemFlags
).
另请参阅
PySide2.QtWidgets.QListWidgetItem.
font
(
)
¶
QFont
Returns the font used to display this list item’s text.
另请参阅
PySide2.QtWidgets.QListWidgetItem.
foreground
(
)
¶
QBrush
Returns the brush used to display the list item’s foreground (e.g. text).
PySide2.QtWidgets.QListWidgetItem.
icon
(
)
¶
QIcon
Returns the list item’s icon.
PySide2.QtWidgets.QListWidgetItem.
isHidden
(
)
¶
bool
返回
true
if the item is hidden; otherwise returns
false
.
另请参阅
PySide2.QtWidgets.QListWidgetItem.
isSelected
(
)
¶
bool
返回
true
if the item is selected; otherwise returns
false
.
另请参阅
PySide2.QtWidgets.QListWidgetItem.
listWidget
(
)
¶
Returns the list widget containing the item.
PySide2.QtWidgets.QListWidgetItem.
__lt__
(
other
)
¶
other
–
QListWidgetItem
bool
PySide2.QtWidgets.QListWidgetItem.
setBackground
(
brush
)
¶
brush
–
QBrush
Sets the background brush of the list item to the given
brush
。设置默认构造的笔刷将使视图使用来自样式的默认颜色。
PySide2.QtWidgets.QListWidgetItem.
setBackgroundColor
(
color
)
¶
color
–
QColor
注意
此函数被弃用。
This function is deprecated. Use
setBackground()
代替。
另请参阅
PySide2.QtWidgets.QListWidgetItem.
setCheckState
(
state
)
¶
state
–
CheckState
Sets the check state of the list item to
state
.
另请参阅
PySide2.QtWidgets.QListWidgetItem.
setData
(
role
,
value
)
¶
role
–
int
value – object
Sets the data for a given
role
到给定
value
. Reimplement this function if you need extra roles or special behavior for certain roles.
注意
默认实现视
EditRole
and
DisplayRole
为引用相同数据。
另请参阅
ItemDataRole
data()
PySide2.QtWidgets.QListWidgetItem.
setFlags
(
flags
)
¶
flags
–
ItemFlags
Sets the item flags for the list item to
flags
.
另请参阅
flags()
ItemFlags
PySide2.QtWidgets.QListWidgetItem.
setFont
(
font
)
¶
font
–
QFont
Sets the font used when painting the item to the given
font
.
另请参阅
PySide2.QtWidgets.QListWidgetItem.
setForeground
(
brush
)
¶
brush
–
QBrush
Sets the foreground brush of the list item to the given
brush
。设置默认构造的笔刷将使视图使用来自样式的默认颜色。
PySide2.QtWidgets.QListWidgetItem.
setHidden
(
hide
)
¶
hide
–
bool
隐藏项若
hide
is true; otherwise shows the item.
另请参阅
PySide2.QtWidgets.QListWidgetItem.
setIcon
(
icon
)
¶
icon
–
QIcon
Sets the icon for the list item to the given
icon
.
PySide2.QtWidgets.QListWidgetItem.
setSelected
(
select
)
¶
select
–
bool
将项的选定状态设为
select
.
另请参阅
PySide2.QtWidgets.QListWidgetItem.
setSizeHint
(
size
)
¶
size
–
QSize
Sets the size hint for the list item to be
size
。若没有设置尺寸提示或
size
无效,项委托将基于项数据计算尺寸提示。
另请参阅
PySide2.QtWidgets.QListWidgetItem.
setStatusTip
(
statusTip
)
¶
statusTip – unicode
Sets the status tip for the list item to the text specified by
statusTip
.
QListWidget
mouseTracking needs to be enabled for this feature to work.
PySide2.QtWidgets.QListWidgetItem.
setText
(
text
)
¶
text – unicode
Sets the text for the list widget item’s to the given
text
.
另请参阅
PySide2.QtWidgets.QListWidgetItem.
setTextAlignment
(
alignment
)
¶
alignment
–
int
Sets the list item’s text alignment to
alignment
.
另请参阅
textAlignment()
AlignmentFlag
PySide2.QtWidgets.QListWidgetItem.
setTextColor
(
color
)
¶
color
–
QColor
注意
此函数被弃用。
This function is deprecated. Use
setForeground()
代替。
另请参阅
PySide2.QtWidgets.QListWidgetItem.
setToolTip
(
toolTip
)
¶
toolTip – unicode
Sets the tooltip for the list item to the text specified by
toolTip
.
PySide2.QtWidgets.QListWidgetItem.
setWhatsThis
(
whatsThis
)
¶
whatsThis – unicode
Sets the “What’s This?” help for the list item to the text specified by
whatsThis
.
PySide2.QtWidgets.QListWidgetItem.
sizeHint
(
)
¶
QSize
返回列表项的大小提示设置。
另请参阅
PySide2.QtWidgets.QListWidgetItem.
statusTip
(
)
¶
unicode
Returns the list item’s status tip.
另请参阅
PySide2.QtWidgets.QListWidgetItem.
text
(
)
¶
unicode
Returns the list item’s text.
另请参阅
PySide2.QtWidgets.QListWidgetItem.
textAlignment
(
)
¶
int
返回列表项的文本对齐方式。
另请参阅
setTextAlignment()
AlignmentFlag
PySide2.QtWidgets.QListWidgetItem.
textColor
(
)
¶
QColor
注意
此函数被弃用。
Returns the color used to display the list item’s text.
This function is deprecated. Use
foreground()
代替。
另请参阅
PySide2.QtWidgets.QListWidgetItem.
toolTip
(
)
¶
unicode
Returns the list item’s tooltip.
PySide2.QtWidgets.QListWidgetItem.
type
(
)
¶
int
返回类型被传递给
QListWidgetItem
构造函数。
PySide2.QtWidgets.QListWidgetItem.
whatsThis
(
)
¶
unicode
Returns the list item’s “What’s This?” help text.