QTreeWidgetItemclass provides an item for use with theQTreeWidget方便类。 更多 …
def
addChild
(child)
def
addChildren
(children)
def
background
(column)
def
backgroundColor
(column)
def
checkState
(column)
def
child
(index)
def
childCount
()
def
childIndicatorPolicy
()
def
columnCount
()
def
emitDataChanged
()
def
flags
()
def
font
(column)
def
foreground
(column)
def
icon
(column)
def
indexOfChild
(child)
def
insertChild
(index, child)
def
insertChildren
(index, children)
def
isDisabled
()
def
isExpanded
()
def
isFirstColumnSpanned
()
def
isHidden
()
def
isSelected
()
def
parent
()
def
removeChild
(child)
def
setBackground
(column, brush)
def
setBackgroundColor
(column, color)
def
setCheckState
(column, state)
def
setChildIndicatorPolicy
(policy)
def
setDisabled
(disabled)
def
setExpanded
(expand)
def
setFirstColumnSpanned
(span)
def
setFlags
(flags)
def
setFont
(column, font)
def
setForeground
(column, brush)
def
setHidden
(hide)
def
setIcon
(column, icon)
def
setSelected
(select)
def
setSizeHint
(column, size)
def
setStatusTip
(column, statusTip)
def
setText
(column, text)
def
setTextAlignment
(column, alignment)
def
setTextColor
(column, color)
def
setToolTip
(column, toolTip)
def
setWhatsThis
(column, whatsThis)
def
sizeHint
(column)
def
sortChildren
(column, order)
def
statusTip
(column)
def
takeChild
(index)
def
takeChildren
()
def
text
(column)
def
textAlignment
(column)
def
textColor
(column)
def
toolTip
(column)
def
treeWidget
()
def
type
()
def
whatsThis
(column)
树 Widget 项用于保持树小部件的信息行。行通常包含几列数据,每列数据可以包含文本标签和图标。
QTreeWidgetItemclass is a convenience class that replaces the QListViewItem class in Qt 3. It provides an item for use with theQTreeWidget类。项构造通常采用的父级要么是
QTreeWidget(for top-level items) or aQTreeWidgetItem(for items on lower levels of the tree). For example, the following code constructs a top-level item to represent cities of the world, and adds a entry for Oslo as a child item:cities = QTreeWidgetItem(treeWidget) cities.setText(0, tr("Cities")) osloItem = QTreeWidgetItem(cities) osloItem.setText(0, tr("Oslo")) osloItem.setText(1, tr("Yes"))通过指定它们所跟随的项可以按特定次序添加项,当构造它们时:
planets = QTreeWidgetItem(treeWidget, cities) planets.setText(0, tr("Planets"))项中每列可以拥有自己的背景笔刷,设置采用
setBackground()function. The current background brush can be found withbackground(). The text label for each column can be rendered with its own font and brush. These are specified with thesetFont()andsetForeground()functions, and read withfont()andforeground().顶层项和树中较低级项的主要差异是顶层项没有
parent(). This information can be used to tell the difference between items, and is useful to know when inserting and removing items from the tree. Children of an item can be removed withtakeChild()and inserted at a given index in the list of children with theinsertChild()函数。By default, items are enabled, selectable, checkable, and can be the source of a drag and drop operation. Each item’s flags can be changed by calling
setFlags()with the appropriate value (seeItemFlags)。可复选项可以被复选和取消复选采用setCheckState()function. The correspondingcheckState()function indicates whether the item is currently checked.
当子类化
QTreeWidgetItemto provide custom items, it is possible to define new types for them so that they can be distinguished from standard items. The constructors for subclasses that require this feature need to call the base class constructor with a new type value equal to or greater thanUserType.
QTreeWidgetItem
(
treeview
,
after
[
,
type=Type
]
)
¶
QTreeWidgetItem(treeview, strings[, type=Type])
QTreeWidgetItem(treeview[, type=Type])
QTreeWidgetItem(parent, after[, type=Type])
QTreeWidgetItem(parent, strings[, type=Type])
QTreeWidgetItem(parent[, type=Type])
QTreeWidgetItem(strings[, type=Type])
QTreeWidgetItem(other)
QTreeWidgetItem([type=Type])
- param type
int- param parent
- param strings
字符串列表
- param treeview
- param after
- param other
构造树 Widget 项采用指定
type
并将其插入给定
parent
后于
preceding
项。
另请参阅
构造树 Widget 项采用指定
type
并将其追加到项在给定
parent
.
另请参阅
构造树 Widget 项采用指定
type
其被插入
parent
后于
preceding
子级项。
另请参阅
构造树 Widget 项并将其追加到给定
parent
.
另请参阅
构造树 Widget 项采用指定
type
。项必须被插入树 Widget。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
ItemType
¶
此枚举描述用于描述树 Widget 项的类型。
|
常量 |
描述 |
|---|---|
|
QTreeWidgetItem.Type |
用于树 Widget 项的默认类型。 |
|
QTreeWidgetItem.UserType |
The minimum value for custom types. Values below are reserved by Qt. |
可以定义新用户类型在
QTreeWidgetItem
子类以确保自定义项得到特殊处理;例如,当排序项时。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
ChildIndicatorPolicy
¶
|
常量 |
描述 |
|---|---|
|
QTreeWidgetItem.ShowIndicator |
将展示此项的展开和折叠控件,即使没有子级。 |
|
QTreeWidgetItem.DontShowIndicator |
从不展示用于展开和折叠的控件,即使有子级。若节点被强制打开,用户将无法展开或折叠项。 |
|
QTreeWidgetItem.DontShowIndicatorWhenChildless |
将展示用于展开和折叠的控件,若项包含子级。 |
PySide2.QtWidgets.QTreeWidgetItem.
addChild
(
child
)
¶
child
–
QTreeWidgetItem
追加
child
项到子级列表。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
addChildren
(
children
)
¶
children –
追加给定列表
children
到项。
PySide2.QtWidgets.QTreeWidgetItem.
background
(
column
)
¶
column
–
int
QBrush
返回用于渲染背景的笔刷为指定
column
.
PySide2.QtWidgets.QTreeWidgetItem.
backgroundColor
(
column
)
¶
column
–
int
QColor
注意
此函数被弃用。
This function is deprecated. Use
background()
代替。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
checkState
(
column
)
¶
column
–
int
CheckState
返回标签的校验状态在给定
column
.
另请参阅
setCheckState()
CheckState
PySide2.QtWidgets.QTreeWidgetItem.
child
(
index
)
¶
index
–
int
返回项位于给定
index
in the list of the item’s children.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
childCount
(
)
¶
int
返回子级项数。
PySide2.QtWidgets.QTreeWidgetItem.
childIndicatorPolicy
(
)
¶
返回项指示符策略。此策略决定何时展示树分支展开/折叠指示符。
PySide2.QtWidgets.QTreeWidgetItem.
clone
(
)
¶
创建项及其子级的深拷贝。
PySide2.QtWidgets.QTreeWidgetItem.
columnCount
(
)
¶
int
返回项中的列数。
PySide2.QtWidgets.QTreeWidgetItem.
data
(
column
,
role
)
¶
column
–
int
role
–
int
object
Returns the value for the item’s
column
and
role
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
emitDataChanged
(
)
¶
促使关联此项的模型发射
dataChanged
() 信号对于此项。
通常只需调用此函数若有子类化
QTreeWidgetItem
和重实现
data()
and/or
setData()
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
flags
(
)
¶
ItemFlags
返回用于描述项的标志。这些确定项是否可以被复选、编辑及选择。
标志的默认值为
ItemIsSelectable
|
ItemIsUserCheckable
|
ItemIsEnabled
|
ItemIsDragEnabled
|
ItemIsDropEnabled
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
font
(
column
)
¶
column
–
int
QFont
返回用于渲染文本的字体在指定
column
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
foreground
(
column
)
¶
column
–
int
QBrush
返回用于渲染前景 (如:文本) 的笔刷为指定
column
。设置默认构造的笔刷将使视图使用来自样式的默认颜色。
PySide2.QtWidgets.QTreeWidgetItem.
icon
(
column
)
¶
column
–
int
QIcon
返回的图标显示在指定
column
.
PySide2.QtWidgets.QTreeWidgetItem.
indexOfChild
(
child
)
¶
child
–
QTreeWidgetItem
int
返回索引为给定
child
in the item’s list of children.
PySide2.QtWidgets.QTreeWidgetItem.
insertChild
(
index
,
child
)
¶
index
–
int
child
–
QTreeWidgetItem
插入
child
项在
index
在子级列表。
If the child has already been inserted somewhere else it won’t be inserted again.
PySide2.QtWidgets.QTreeWidgetItem.
insertChildren
(
index
,
children
)
¶
index
–
int
children –
插入给定列表为
children
进项子级列表在
index
.
Children that have already been inserted somewhere else won’t be inserted.
PySide2.QtWidgets.QTreeWidgetItem.
isDisabled
(
)
¶
bool
返回
true
若项被禁用;否则返回
false
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
isExpanded
(
)
¶
bool
返回
true
若项被展开,否则返回
false
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
isFirstColumnSpanned
(
)
¶
bool
返回
true
若项跨行中所有列;否则返回
false
.
PySide2.QtWidgets.QTreeWidgetItem.
isHidden
(
)
¶
bool
返回
true
若项被隐藏,否则返回
false
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
isSelected
(
)
¶
bool
返回
true
若项被选中,否则返回
false
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
__lt__
(
other
)
¶
other
–
QTreeWidgetItem
bool
PySide2.QtWidgets.QTreeWidgetItem.
parent
(
)
¶
Returns the item’s parent.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
read
(
in
)
¶
in
–
QDataStream
读取项从流
in
。这只将数据读取到单项。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
removeChild
(
child
)
¶
child
–
QTreeWidgetItem
删除给定项指示通过
child
。移除项不会被删除。
PySide2.QtWidgets.QTreeWidgetItem.
setBackground
(
column
,
brush
)
¶
column
–
int
brush
–
QBrush
设置标签背景笔刷在给定
column
到指定
brush
。设置默认构造的笔刷将使视图使用来自样式的默认颜色。
注意
若 Qt 样式表 are used on the same widget as , style sheets will take precedence if the settings conflict.
PySide2.QtWidgets.QTreeWidgetItem.
setBackgroundColor
(
column
,
color
)
¶
column
–
int
color
–
QColor
注意
此函数被弃用。
This function is deprecated. Use
setBackground()
代替。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
setCheckState
(
column
,
state
)
¶
column
–
int
state
–
CheckState
设置项在给定
column
复选状态为
state
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
setChildIndicatorPolicy
(
policy
)
¶
policy
–
ChildIndicatorPolicy
设置项指示器
policy
. This policy decides when the tree branch expand/collapse indicator is shown. The default value is ShowForChildren.
PySide2.QtWidgets.QTreeWidgetItem.
setData
(
column
,
role
,
value
)
¶
column
–
int
role
–
int
value – object
Sets the value for the item’s
column
and
role
到给定
value
.
role
描述数据类型指定通过
value
,和定义通过
ItemDataRole
枚举。
注意
默认实现视
EditRole
and
DisplayRole
为引用相同数据。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
setDisabled
(
disabled
)
¶
disabled
–
bool
禁用项若
disabled
为 true;否则启用项。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
setExpanded
(
expand
)
¶
expand
–
bool
展开项若
expand
为 true,否则折叠项。
警告
QTreeWidgetItem
必须被添加到
QTreeWidget
在调用此函数之前。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
setFirstColumnSpanned
(
span
)
¶
span
–
bool
把第 1 区间设为跨所有列若
span
为 true;否则展示所有项区间。
PySide2.QtWidgets.QTreeWidgetItem.
setFlags
(
flags
)
¶
flags
–
ItemFlags
将项的标志设为给定
flags
。这些确定是否可以选择或修改项。这经常用于禁用项。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
setFont
(
column
,
font
)
¶
column
–
int
font
–
QFont
设置用于显示文本的字体在给定
column
到给定
font
.
PySide2.QtWidgets.QTreeWidgetItem.
setForeground
(
column
,
brush
)
¶
column
–
int
brush
–
QBrush
设置标签的前景笔刷在给定
column
到指定
brush
.
PySide2.QtWidgets.QTreeWidgetItem.
setHidden
(
hide
)
¶
hide
–
bool
隐藏项若
hide
为 True,否则展示项。
注意
调用此函数不起作用,若项目前不在视图中。尤其,调用
setHidden(true)
在项,然后才将它添加到视图会导致项可见。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
setIcon
(
column
,
icon
)
¶
column
–
int
icon
–
QIcon
设置要显示的图标在给定
column
to
icon
.
PySide2.QtWidgets.QTreeWidgetItem.
setSelected
(
select
)
¶
select
–
bool
将项的选定状态设为
select
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
setSizeHint
(
column
,
size
)
¶
column
–
int
size
–
QSize
设置树项尺寸提示在给定
column
to be
size
。若没有设置尺寸提示或
size
无效,项委托将基于项数据计算尺寸提示。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
setStatusTip
(
column
,
statusTip
)
¶
column
–
int
statusTip – unicode
设置状态提示为给定
column
到给定
statusTip
.
QTreeWidget
鼠标跟踪需要被启用此特征才工作。
PySide2.QtWidgets.QTreeWidgetItem.
setText
(
column
,
text
)
¶
column
–
int
text – unicode
设置要显示的文本在给定
column
到给定
text
.
PySide2.QtWidgets.QTreeWidgetItem.
setTextAlignment
(
column
,
alignment
)
¶
column
–
int
alignment
–
int
设置标签的文本对齐方式在给定
column
到
alignment
指定 (见
AlignmentFlag
).
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
setTextColor
(
column
,
color
)
¶
column
–
int
color
–
QColor
注意
此函数被弃用。
This function is deprecated. Use
setForeground()
代替。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
setToolTip
(
column
,
toolTip
)
¶
column
–
int
toolTip – unicode
设置工具提示为给定
column
to
toolTip
.
PySide2.QtWidgets.QTreeWidgetItem.
setWhatsThis
(
column
,
whatsThis
)
¶
column
–
int
whatsThis – unicode
Sets the “What’s This?” help for the given
column
to
whatsThis
.
PySide2.QtWidgets.QTreeWidgetItem.
sizeHint
(
column
)
¶
column
–
int
QSize
返回为树项设置的尺寸提示在给定
column
(见
QSize
).
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
sortChildren
(
column
,
order
)
¶
column
–
int
order
–
SortOrder
排序项的子级使用给定
order
,通过值在给定
column
.
注意
此函数什么都不做,若项不关联
QTreeWidget
.
PySide2.QtWidgets.QTreeWidgetItem.
statusTip
(
column
)
¶
column
–
int
unicode
返回状态提示内容为给定
column
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
takeChild
(
index
)
¶
index
–
int
移除项在
index
并返回它,否则返回 0。
PySide2.QtWidgets.QTreeWidgetItem.
takeChildren
(
)
¶
移除子级列表并返回它,否则返回空列表。
PySide2.QtWidgets.QTreeWidgetItem.
text
(
column
)
¶
column
–
int
unicode
返回文本在指定
column
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
textAlignment
(
column
)
¶
column
–
int
int
返回标签的文本对齐方式在给定
column
(见
AlignmentFlag
).
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
textColor
(
column
)
¶
column
–
int
QColor
注意
此函数被弃用。
This function is deprecated. Use
foreground()
代替。
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
toolTip
(
column
)
¶
column
–
int
unicode
返回工具提示为给定
column
.
另请参阅
PySide2.QtWidgets.QTreeWidgetItem.
treeWidget
(
)
¶
返回包含项的树 Widget。
PySide2.QtWidgets.QTreeWidgetItem.
type
(
)
¶
int
返回类型被传递给
QTreeWidgetItem
构造函数。
PySide2.QtWidgets.QTreeWidgetItem.
whatsThis
(
column
)
¶
column
–
int
unicode
Returns the “What’s This?” help for the contents of the given
column
.
另请参阅