PySide.QtGui.QTreeWidgetItem class provides an item for use with the PySide.QtGui.QTreeWidget 方便类。
树 Widget 项用于保持树小部件的信息行。行通常包含几列数据,每列数据可以包含文本标签和图标。
PySide.QtGui.QTreeWidgetItem class is a convenience class that replaces the QListViewItem class in Qt 3. It provides an item for use with the PySide.QtGui.QTreeWidget 类。
项构造通常采用的父级要么是 PySide.QtGui.QTreeWidget (for top-level items) or a PySide.QtGui.QTreeWidgetItem (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"))
项中每列可以拥有自己的背景笔刷,设置采用 PySide.QtGui.QTreeWidgetItem.setBackground() function. The current background brush can be found with PySide.QtGui.QTreeWidgetItem.background() . The text label for each column can be rendered with its own font and brush. These are specified with the PySide.QtGui.QTreeWidgetItem.setFont() and PySide.QtGui.QTreeWidgetItem.setForeground() functions, and read with PySide.QtGui.QTreeWidgetItem.font() and PySide.QtGui.QTreeWidgetItem.foreground() .
顶层项和树中较低级项的主要差异是顶层项没有 PySide.QtGui.QTreeWidgetItem.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 with PySide.QtGui.QTreeWidgetItem.takeChild() and inserted at a given index in the list of children with the PySide.QtGui.QTreeWidgetItem.insertChild() 函数。
默认情况下,项是启用的、可选择的、可复选的及可以是拖放操作的来源。可以改变每项的标志通过调用 PySide.QtGui.QTreeWidgetItem.setFlags() with the appropriate value (see Qt.ItemFlags )。可复选项可以被复选和取消复选采用 PySide.QtGui.QTreeWidgetItem.setCheckState() function. The corresponding PySide.QtGui.QTreeWidgetItem.checkState() function indicates whether the item is currently checked.
当子类化 PySide.QtGui.QTreeWidgetItem to 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 than UserType .
| 参数: |
|
|---|
构造树 Widget 项采用指定 type 并将其插入给定 parent 后于 preceding 项。
构造树 Widget 项采用指定 type 并将其追加到项在给定 parent 。给定列表 strings 将被设置作为项中每列的项文本。
构造树 Widget 项采用指定 type 并将其追加到项在给定 parent .
构造树 Widget 项采用指定 type 其被插入 parent 后于 preceding 子级项。
构造树 Widget 项并将其追加到给定 parent 。给定列表 strings 将被设置作为项中每列的项文本。
构造树 Widget 项并将其追加到给定 parent .
构造树 Widget 项采用指定 type 。项必须被插入树小部件。给定列表的 strings 将被设置作为项中每列的项文本。
构造副本为 other 。注意 PySide.QtGui.QTreeWidgetItem.type() and PySide.QtGui.QTreeWidgetItem.treeWidget() are not copied.
此函数是有用的,当重实现 PySide.QtGui.QTreeWidgetItem.clone() .
构造树 Widget 项采用指定 type 。项必须被插入树 Widget。
此枚举描述用于描述树 Widget 项的类型。
| 常量 | 描述 |
|---|---|
| QTreeWidgetItem.Type | 用于树 Widget 项的默认类型。 |
| QTreeWidgetItem.UserType | The minimum value for custom types. Values below UserType are reserved by Qt. |
可以定义新用户类型在 PySide.QtGui.QTreeWidgetItem 子类以确保自定义项得到特殊处理;例如,当排序项时。
| 常量 | 描述 |
|---|---|
| QTreeWidgetItem.ShowIndicator | 将展示此项的展开和折叠控件,即使没有子级。 |
| QTreeWidgetItem.DontShowIndicator | 从不展示用于展开和折叠的控件,即使有子级。若节点被强制打开,用户将无法展开或折叠项。 |
| QTreeWidgetItem.DontShowIndicatorWhenChildless | 将展示用于展开和折叠的控件,若项包含子级。 |
| 参数: | child – PySide.QtGui.QTreeWidgetItem |
|---|
追加 child 项到子级列表。
| 参数: | children – |
|---|
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtGui.QBrush |
返回用于渲染背景的笔刷为指定 column .
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.Qt.CheckState |
返回标签的校验状态在给定 column .
另请参阅
PySide.QtGui.QTreeWidgetItem.setCheckState() Qt.CheckState
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtGui.QTreeWidgetItem |
返回项位于给定 index 在项的子级列表中。
| 返回类型: | PySide.QtCore.int |
|---|
返回子级项数。
| 返回类型: | PySide.QtGui.QTreeWidgetItem.ChildIndicatorPolicy |
|---|
返回项指示符策略。此策略决定何时展示树分支展开/折叠指示符。
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | object |
| 返回类型: | PySide.QtGui.QTreeWidgetItem |
|---|
创建项及其子级的深拷贝。
| 返回类型: | PySide.QtCore.int |
|---|
返回项中的列数。
| 参数: |
|
|---|---|
| 返回类型: |
object |
返回值对于项的 column and role .
促使关联此项的模型发射 PySide.QtCore.QAbstractItemModel.dataChanged() () 信号对于此项。
通常只需调用此函数若有子类化 PySide.QtGui.QTreeWidgetItem 和重实现 PySide.QtGui.QTreeWidgetItem.data() and/or PySide.QtGui.QTreeWidgetItem.setData() .
| 返回类型: | PySide.QtCore.Qt.ItemFlags |
|---|
返回用于描述项的标志。这些确定项是否可以被复选、编辑及选择。
标志的默认值为 Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled . If the item was constructed with a parent, flags will in addition contain Qt.ItemIsDropEnabled .
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtGui.QFont |
返回用于渲染文本的字体在指定 column .
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtGui.QBrush |
返回用于渲染前景 (如:文本) 的笔刷为指定 column .
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtGui.QIcon |
返回的图标显示在指定 column .
| 参数: | child – PySide.QtGui.QTreeWidgetItem |
|---|---|
| 返回类型: | PySide.QtCore.int |
返回索引为给定 child 在项的子级列表中。
| 参数: |
|
|---|
插入 child 项在 index 在子级列表。
If the child has already been inserted somewhere else it wont be inserted again.
| 参数: |
|
|---|
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if the item is disabled; otherwise returns false.
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if the item is expanded, otherwise returns false.
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if the item is spanning all the columns in a row; otherwise returns false.
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if the item is hidden, otherwise returns false.
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if the item is selected, otherwise returns false.
| 参数: | other – PySide.QtGui.QTreeWidgetItem |
|---|---|
| 返回类型: | PySide.QtCore.bool |
Returns true if the text in the item is less than the text in the other item, otherwise returns false.
| 返回类型: | PySide.QtGui.QTreeWidgetItem |
|---|
返回项的父级。
| 参数: | in – PySide.QtCore.QDataStream |
|---|
读取项从流 in 。这只将数据读取到单项。
| 参数: | child – PySide.QtGui.QTreeWidgetItem |
|---|
删除给定项指示通过 child 。移除项不会被删除。
| 参数: |
|
|---|
设置标签背景笔刷在给定 column 到指定 brush .
| 参数: |
|
|---|
| 参数: | policy – PySide.QtGui.QTreeWidgetItem.ChildIndicatorPolicy |
|---|
| 参数: |
|
|---|
设置值对于项的 column and role 到给定 value .
role 描述数据类型指定通过 value ,和定义通过 Qt.ItemDataRole 枚举。
| 参数: | disabled – PySide.QtCore.bool |
|---|
禁用项若 disabled 为 true;否则启用项。
| 参数: | expand – PySide.QtCore.bool |
|---|
展开项若 expand 为 true,否则折叠项。
警告
PySide.QtGui.QTreeWidgetItem 必须被添加到 PySide.QtGui.QTreeWidget 在调用此函数之前。
| 参数: | span – PySide.QtCore.bool |
|---|
把第 1 区间设为跨所有列若 span 为 true;否则展示所有项区间。
| 参数: | flags – PySide.QtCore.Qt.ItemFlags |
|---|
| 参数: |
|
|---|
设置用于显示文本的字体在给定 column 到给定 font .
| 参数: |
|
|---|
设置标签的前景笔刷在给定 column 到指定 brush .
| 参数: | hide – PySide.QtCore.bool |
|---|
隐藏项若 hide 为 True,否则展示项。
| 参数: |
|
|---|
设置要显示的图标在给定 column to icon .
| 参数: | select – PySide.QtCore.bool |
|---|
将项的选定状态设为 select .
| 参数: |
|
|---|
设置树项尺寸提示在给定 column to be size . If no size hint is set, the item delegate will compute the size hint based on the item data.
| 参数: |
|
|---|
设置状态提示为给定 column 到给定 statusTip . PySide.QtGui.QTreeWidget 鼠标跟踪需要被启用此特征才工作。
| 参数: |
|
|---|
设置要显示的文本在给定 column 到给定 text .
| 参数: |
|
|---|
设置标签的文本对齐方式在给定 column 到 alignment 指定 (见 Qt.AlignmentFlag ).
| 参数: |
|
|---|
设置工具提示为给定 column to toolTip .
| 参数: |
|
|---|
Sets the “What's This?” help for the given column to whatsThis .
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.QSize |
返回为树项设置的尺寸提示在给定 column (见 PySide.QtCore.QSize ).
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | unicode |
返回状态提示内容为给定 column .
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtGui.QTreeWidgetItem |
移除项在 index 并返回它,否则返回 0。
| 返回类型: |
|---|
移除子级列表并返回它,否则返回空列表。
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | unicode |
返回文本在指定 column .
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.int |
返回标签的文本对齐方式在给定 column (见 Qt.AlignmentFlag ).
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | unicode |
返回工具提示为给定 column .
| 返回类型: | PySide.QtGui.QTreeWidget |
|---|
返回包含项的树 Widget。
| 返回类型: | PySide.QtCore.int |
|---|
返回类型被传递给 PySide.QtGui.QTreeWidgetItem 构造函数。
| 参数: | column – PySide.QtCore.int |
|---|---|
| 返回类型: | unicode |
Returns the “What's This?” help for the contents of the given column .
| 参数: | out – PySide.QtCore.QDataStream |
|---|
把项写入流 out 。这仅从一单项写入数据。