The PySide.QtGui.QTreeWidgetItem class provides an item for use with the PySide.QtGui.QTreeWidget convenience class.
Tree widget items are used to hold rows of information for tree widgets. Rows usually contain several columns of data, each of which can contain a text label and an icon.
The 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 class.
Items are usually constructed with a parent that is either a 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"))Items can be added in a particular order by specifying the item they follow when they are constructed:
planets = QTreeWidgetItem(treeWidget, cities) planets.setText(0, tr("Planets"))Each column in an item can have its own background brush which is set with the 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() .
The main difference between top-level items and those in lower levels of the tree is that a top-level item has no 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() function.
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 PySide.QtGui.QTreeWidgetItem.setFlags() with the appropriate value (see Qt.ItemFlags ). Checkable items can be checked and unchecked with the PySide.QtGui.QTreeWidgetItem.setCheckState() function. The corresponding PySide.QtGui.QTreeWidgetItem.checkState() function indicates whether the item is currently checked.
When subclassing 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 .
See also
PySide.QtGui.QTreeWidget PySide.QtGui.QTreeWidgetItemIterator Model/View Programming PySide.QtGui.QListWidgetItem PySide.QtGui.QTableWidgetItem
Parameters: |
|
---|
Constructs a tree widget item of the specified type and inserts it into the given parent after the preceding item.
See also
Constructs a tree widget item of the specified type and appends it to the items in the given parent . The given list of strings will be set as the item text for each column in the item.
See also
Constructs a tree widget item of the specified type and appends it to the items in the given parent .
See also
Constructs a tree widget item of the specified type that is inserted into the parent after the preceding child item.
See also
Constructs a tree widget item and append it to the given parent . The given list of strings will be set as the item text for each column in the item.
See also
Constructs a tree widget item and append it to the given parent .
See also
Constructs a tree widget item of the specified type . The item must be inserted into a tree widget. The given list of strings will be set as the item text for each column in the item.
See also
Constructs a copy of other . Note that PySide.QtGui.QTreeWidgetItem.type() and PySide.QtGui.QTreeWidgetItem.treeWidget() are not copied.
This function is useful when reimplementing PySide.QtGui.QTreeWidgetItem.clone() .
Constructs a tree widget item of the specified type . The item must be inserted into a tree widget.
See also
This enum describes the types that are used to describe tree widget items.
Constant | Description |
---|---|
QTreeWidgetItem.Type | The default type for tree widget items. |
QTreeWidgetItem.UserType | The minimum value for custom types. Values below UserType are reserved by Qt. |
You can define new user types in PySide.QtGui.QTreeWidgetItem subclasses to ensure that custom items are treated specially; for example, when items are sorted.
See also
Constant | Description |
---|---|
QTreeWidgetItem.ShowIndicator | The controls for expanding and collapsing will be shown for this item even if there are no children. |
QTreeWidgetItem.DontShowIndicator | The controls for expanding and collapsing will never be shown even if there are children. If the node is forced open the user will not be able to expand or collapse the item. |
QTreeWidgetItem.DontShowIndicatorWhenChildless | The controls for expanding and collapsing will be shown if the item contains children. |
Parameters: | child – PySide.QtGui.QTreeWidgetItem |
---|
Appends the child item to the list of children.
Parameters: | children – |
---|
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtGui.QBrush |
Returns the brush used to render the background of the specified column .
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.Qt.CheckState |
Returns the check state of the label in the given column .
See also
PySide.QtGui.QTreeWidgetItem.setCheckState() Qt.CheckState
Parameters: | index – PySide.QtCore.int |
---|---|
Return type: | PySide.QtGui.QTreeWidgetItem |
Returns the item at the given index in the list of the item’s children.
Return type: | PySide.QtCore.int |
---|
Returns the number of child items.
Return type: | PySide.QtGui.QTreeWidgetItem.ChildIndicatorPolicy |
---|
Returns the item indicator policy. This policy decides when the tree branch expand/collapse indicator is shown.
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | object |
Return type: | PySide.QtGui.QTreeWidgetItem |
---|
Creates a deep copy of the item and of its children.
Return type: | PySide.QtCore.int |
---|
Returns the number of columns in the item.
Parameters: |
|
---|---|
Return type: | object |
Returns the value for the item’s column and role .
Causes the model associated with this item to emit a PySide.QtCore.QAbstractItemModel.dataChanged() () signal for this item.
You normally only need to call this function if you have subclassed PySide.QtGui.QTreeWidgetItem and reimplemented PySide.QtGui.QTreeWidgetItem.data() and/or PySide.QtGui.QTreeWidgetItem.setData() .
Return type: | PySide.QtCore.Qt.ItemFlags |
---|
Returns the flags used to describe the item. These determine whether the item can be checked, edited, and selected.
The default value for flags is Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled . If the item was constructed with a parent, flags will in addition contain Qt.ItemIsDropEnabled .
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtGui.QFont |
Returns the font used to render the text in the specified column .
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtGui.QBrush |
Returns the brush used to render the foreground (e.g. text) of the specified column .
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtGui.QIcon |
Returns the icon that is displayed in the specified column .
Parameters: | child – PySide.QtGui.QTreeWidgetItem |
---|---|
Return type: | PySide.QtCore.int |
Returns the index of the given child in the item’s list of children.
Parameters: |
|
---|
Inserts the child item at index in the list of children.
If the child has already been inserted somewhere else it wont be inserted again.
Parameters: |
|
---|
Return type: | PySide.QtCore.bool |
---|
Returns true if the item is disabled; otherwise returns false.
Return type: | PySide.QtCore.bool |
---|
Returns true if the item is expanded, otherwise returns false.
Return type: | PySide.QtCore.bool |
---|
Returns true if the item is spanning all the columns in a row; otherwise returns false.
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.
Parameters: | other – PySide.QtGui.QTreeWidgetItem |
---|---|
Return type: | PySide.QtCore.bool |
Returns true if the text in the item is less than the text in the other item, otherwise returns false.
Return type: | PySide.QtGui.QTreeWidgetItem |
---|
Returns the item’s parent.
See also
Parameters: | in – PySide.QtCore.QDataStream |
---|
Reads the item from stream in . This only reads data into a single item.
See also
Parameters: | child – PySide.QtGui.QTreeWidgetItem |
---|
Removes the given item indicated by child . The removed item will not be deleted.
Parameters: |
|
---|
Sets the background brush of the label in the given column to the specified brush .
Parameters: |
|
---|
Parameters: | policy – PySide.QtGui.QTreeWidgetItem.ChildIndicatorPolicy |
---|
Parameters: |
|
---|
Sets the value for the item’s column and role to the given value .
The role describes the type of data specified by value , and is defined by the Qt.ItemDataRole enum.
See also
Parameters: | disabled – PySide.QtCore.bool |
---|
Disables the item if disabled is true; otherwise enables the item.
Parameters: | expand – PySide.QtCore.bool |
---|
Expands the item if expand is true, otherwise collapses the item.
Warning
The PySide.QtGui.QTreeWidgetItem must be added to the PySide.QtGui.QTreeWidget before calling this function.
Parameters: | span – PySide.QtCore.bool |
---|
Sets the first section to span all columns if span is true; otherwise all item sections are shown.
Parameters: | flags – PySide.QtCore.Qt.ItemFlags |
---|
Parameters: |
|
---|
Sets the font used to display the text in the given column to the given font .
Parameters: |
|
---|
Sets the foreground brush of the label in the given column to the specified brush .
Parameters: | hide – PySide.QtCore.bool |
---|
Hides the item if hide is true, otherwise shows the item.
Parameters: |
|
---|
Sets the icon to be displayed in the given column to icon .
Parameters: | select – PySide.QtCore.bool |
---|
Sets the selected state of the item to select .
Parameters: |
|
---|
Sets the size hint for the tree item in the given column to be size . If no size hint is set, the item delegate will compute the size hint based on the item data.
Parameters: |
|
---|
Sets the status tip for the given column to the given statusTip . PySide.QtGui.QTreeWidget mouse tracking needs to be enabled for this feature to work.
Parameters: |
|
---|
Sets the text to be displayed in the given column to the given text .
Parameters: |
|
---|
Sets the text alignment for the label in the given column to the alignment specified (see Qt.AlignmentFlag ).
Parameters: |
|
---|
Sets the tooltip for the given column to toolTip .
Parameters: |
|
---|
Sets the “What’s This?” help for the given column to whatsThis .
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.QSize |
Returns the size hint set for the tree item in the given column (see PySide.QtCore.QSize ).
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | unicode |
Returns the status tip for the contents of the given column .
Parameters: | index – PySide.QtCore.int |
---|---|
Return type: | PySide.QtGui.QTreeWidgetItem |
Removes the item at index and returns it, otherwise return 0.
Return type: |
---|
Removes the list of children and returns it, otherwise returns an empty list.
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | unicode |
Returns the text in the specified column .
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | PySide.QtCore.int |
Returns the text alignment for the label in the given column (see Qt.AlignmentFlag ).
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | unicode |
Returns the tool tip for the given column .
Return type: | PySide.QtGui.QTreeWidget |
---|
Returns the tree widget that contains the item.
Return type: | PySide.QtCore.int |
---|
Returns the type passed to the PySide.QtGui.QTreeWidgetItem constructor.
Parameters: | column – PySide.QtCore.int |
---|---|
Return type: | unicode |
Returns the “What’s This?” help for the contents of the given column .
Parameters: | out – PySide.QtCore.QDataStream |
---|
Writes the item to stream out . This only writes data from one single item.
See also