com.trolltech.qt.gui
Class QTreeWidgetItem

java.lang.Object
  extended by com.trolltech.qt.internal.QSignalEmitterInternal
      extended by com.trolltech.qt.QSignalEmitter
          extended by com.trolltech.qt.QtJambiObject
              extended by com.trolltech.qt.gui.QTreeWidgetItem
All Implemented Interfaces:
QtJambiInterface

public class QTreeWidgetItem
extends QtJambiObject

The QTreeWidgetItem class provides an item for use with the 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 QTreeWidgetItem class is a convenience class that replaces the QListViewItem class in Qt 3. It provides an item for use with the QTreeWidget class.

Items are usually constructed with a parent that is either a QTreeWidget (for top-level items) or a 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:

        QTreeWidgetItem cities = new QTreeWidgetItem(treeWidget);
        cities.setText(0, tr("Cities"));
        QTreeWidgetItem osloItem = new 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:
        QTreeWidgetItem planets = new QTreeWidgetItem(treeWidget, cities);

        planets.setText(0, tr("Planets"));
    
Each column in an item can have its own background brush which is set with the setBackground() function. The current background brush can be found with background(). The text label for each column can be rendered with its own font and brush. These are specified with the setFont() and setForeground() functions, and read with font() and foreground().

The main difference between top-level items and those in lower levels of the tree is that a top-level item has no 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 takeChild() and inserted at a given index in the list of children with the 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 setFlags() with the appropriate value (see Qt::ItemFlags). Checkable items can be checked and unchecked with the setCheckState() function. The corresponding checkState() function indicates whether the item is currently checked.

Subclassing

When subclassing 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:
QTreeWidget, QTreeWidgetItemIterator, Model/View Programming, QListWidgetItem, and QTableWidgetItem.


Nested Class Summary
static class QTreeWidgetItem.ChildIndicatorPolicy
           
static class QTreeWidgetItem.ItemType
          This enum describes the types that are used to describe tree widget items.
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.PrivateSignal0, QSignalEmitter.PrivateSignal1, QSignalEmitter.PrivateSignal2, QSignalEmitter.PrivateSignal3, QSignalEmitter.PrivateSignal4, QSignalEmitter.PrivateSignal5, QSignalEmitter.PrivateSignal6, QSignalEmitter.PrivateSignal7, QSignalEmitter.PrivateSignal8, QSignalEmitter.PrivateSignal9, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9
 
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal
 
Field Summary
 
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
currentSender
 
Constructor Summary
QTreeWidgetItem()
          Constructs a tree widget item of the specified type.
QTreeWidgetItem(int type)
          Constructs a tree widget item of the specified type.
QTreeWidgetItem(java.util.List strings)
          Constructs a tree widget item of the specified type.
QTreeWidgetItem(java.util.List strings, int type)
          Constructs a tree widget item of the specified type.
QTreeWidgetItem(QTreeWidget view)
          Constructs a tree widget item of the specified type and appends it to the items in the given parent.
QTreeWidgetItem(QTreeWidget view, int type)
           
QTreeWidgetItem(QTreeWidgetItem parent)
          Constructs a tree widget item and append it to the given parent.
QTreeWidgetItem(QTreeWidgetItem parent, int type)
          Constructs a tree widget item of the specified type and appends it to the items in the given parent.
QTreeWidgetItem(QTreeWidgetItem parent, java.util.List strings)
          Constructs a tree widget item of the specified type and appends it to the items in the given parent.
QTreeWidgetItem(QTreeWidgetItem parent, java.util.List strings, int type)
          Constructs a tree widget item of the specified type and appends it to the items in the given parent.
QTreeWidgetItem(QTreeWidgetItem parent, QTreeWidgetItem after)
          Constructs a tree widget item of the specified type and inserts it into the given parent after the preceding item.
QTreeWidgetItem(QTreeWidgetItem parent, QTreeWidgetItem after, int type)
          Constructs a tree widget item of the specified type and inserts it into the given parent after the preceding item.
QTreeWidgetItem(QTreeWidget view, java.util.List strings)
           
QTreeWidgetItem(QTreeWidget view, java.util.List strings, int type)
           
QTreeWidgetItem(QTreeWidget view, QTreeWidgetItem after)
           
QTreeWidgetItem(QTreeWidget view, QTreeWidgetItem after, int type)
           
 
Method Summary
 void addChild(QTreeWidgetItem child)
          Appends the child item to the list of children.
 void addChildren(java.util.List children)
          Appends the given list of children to the item.
 QBrush background(int column)
          Returns the brush used to render the background of the specified column.
 Qt.CheckState checkState(int column)
          Returns the check state of the label in the given column.
 QTreeWidgetItem child(int index)
          Returns the item at the given index in the list of the item's children.
 int childCount()
          Returns the number of child items.
 QTreeWidgetItem.ChildIndicatorPolicy childIndicatorPolicy()
          Returns the item indicator policy.
 QTreeWidgetItem clone()
          This method is reimplemented for internal reasons
 int columnCount()
          Returns the number of columns in the item.
 java.lang.Object data(int column, int role)
          Returns the value for the item's column and role.
protected  void emitDataChanged()
          Causes the model associated with this item to emit a dataChanged () signal for this item.
 Qt.ItemFlags flags()
          Returns the flags used to describe the item.
 QFont font(int column)
          Returns the font used to render the text in the specified column.
 QBrush foreground(int column)
          Returns the brush used to render the foreground (e.
 QIcon icon(int column)
          Returns the icon that is displayed in the specified column.
 int indexOfChild(QTreeWidgetItem child)
          Returns the index of the given child in the item's list of children.
 void insertChild(int index, QTreeWidgetItem child)
          Inserts the child item at index in the list of children.
 void insertChildren(int index, java.util.List children)
          Inserts the given list of children into the list of the item children at index .
 boolean isDisabled()
          Returns true if the item is disabled; otherwise returns false.
 boolean isExpanded()
          Returns true if the item is expanded, otherwise returns false.
 boolean isFirstColumnSpanned()
          Returns true if the item is spanning all the columns in a row; otherwise returns false.
 boolean isHidden()
          Returns true if the item is hidden, otherwise returns false.
 boolean isSelected()
          Returns true if the item is selected, otherwise returns false.
 boolean operator_less(QTreeWidgetItem other)
          Returns true if the text in the item is less than the text in the other item, otherwise returns false.
 QTreeWidgetItem parent()
          Returns the item's parent.
 void read(QDataStream in)
          Reads the item from stream in.
 void readFrom(QDataStream in)
          Reads a QTreeWidgetItem
 void removeChild(QTreeWidgetItem child)
          Removes the given item indicated by child.
 void setBackground(int column, QBrush brush)
          Sets the background brush of the label in the given column to the specified brush.
 void setCheckState(int column, Qt.CheckState state)
          Sets the item in the given column check state to be state.
 void setChildIndicatorPolicy(QTreeWidgetItem.ChildIndicatorPolicy policy)
          Sets the item indicator policy.
 void setData(int column, int role, java.lang.Object value)
          Sets the value for the item's column and role to the given value.
 void setDisabled(boolean disabled)
          Disables the item if disabled is true; otherwise enables the item.
 void setExpanded(boolean expand)
          Expands the item if expand is true, otherwise collapses the item.
 void setFirstColumnSpanned(boolean span)
          Sets the first section to span all columns if span is true; otherwise all item sections are shown.
 void setFlags(Qt.ItemFlag[] flags)
          This is an overloaded method provided for convenience.
 void setFlags(Qt.ItemFlags flags)
          Sets the flags for the item to the given flags.
 void setFont(int column, QFont font)
          Sets the font used to display the text in the given column to the given font.
 void setForeground(int column, QBrush brush)
          Sets the foreground brush of the label in the given column to the specified brush.
 void setHidden(boolean hide)
          Hides the item if hide is true, otherwise shows the item.
 void setIcon(int column, QIcon icon)
          Sets the icon to be displayed in the given column to icon.
 void setSelected(boolean select)
          Sets the selected state of the item to select.
 void setSizeHint(int column, QSize size)
          Sets the size hint for the tree item in the given column to be size.
 void setStatusTip(int column, java.lang.String statusTip)
          Sets the status tip for the given column to the given statusTip.
 void setText(int column, java.lang.String text)
          Sets the text to be displayed in the given column to the given text.
 void setTextAlignment(int column, int alignment)
          Sets the text alignment for the label in the given column to the alignment specified (see Qt::AlignmentFlag ).
 void setToolTip(int column, java.lang.String toolTip)
          Sets the tooltip for the given column to toolTip.
 void setWhatsThis(int column, java.lang.String whatsThis)
          Sets the "What's This?" help for the given column to whatsThis.
 QSize sizeHint(int column)
          Returns the size hint set for the tree item in the given column (see QSize).
 void sortChildren(int column, Qt.SortOrder order)
          Sorts the children of the item using the given order, by the values in the given column.
 java.lang.String statusTip(int column)
          Returns the status tip for the contents of the given column.
 QTreeWidgetItem takeChild(int index)
          Removes the item at index and returns it, otherwise return 0.
 java.util.List takeChildren()
          Removes the list of children and returns it, otherwise returns an empty list.
 java.lang.String text(int column)
          Returns the text in the specified column.
 int textAlignment(int column)
          Returns the text alignment for the label in the given column (see Qt::AlignmentFlag ).
 java.lang.String toolTip(int column)
          Returns the tool tip for the given column.
 QTreeWidget treeWidget()
          Returns the tree widget that contains the item.
 int type()
          Returns the type passed to the QTreeWidgetItem constructor.
 java.lang.String whatsThis(int column)
          Returns the "What's This?" help for the contents of the given column.
 void write(QDataStream out)
          Writes the item to stream out.
 void writeTo(QDataStream out)
          Writes thisQTreeWidgetItem
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
__qt_signalInitialization
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QTreeWidgetItem

public QTreeWidgetItem(QTreeWidget view,
                       QTreeWidgetItem after)

QTreeWidgetItem

public QTreeWidgetItem(QTreeWidget view,
                       QTreeWidgetItem after,
                       int type)

QTreeWidgetItem

public QTreeWidgetItem(QTreeWidget view,
                       java.util.List strings)

QTreeWidgetItem

public QTreeWidgetItem(QTreeWidget view,
                       java.util.List strings,
                       int type)

QTreeWidgetItem

public QTreeWidgetItem(QTreeWidget view)
Constructs a tree widget item of the specified type and appends it to the items in the given parent.

See also:
type().


QTreeWidgetItem

public QTreeWidgetItem(QTreeWidget view,
                       int type)

QTreeWidgetItem

public QTreeWidgetItem(QTreeWidgetItem parent,
                       QTreeWidgetItem after)
Constructs a tree widget item of the specified type and inserts it into the given parent after the preceding item.

See also:
type().


QTreeWidgetItem

public QTreeWidgetItem(QTreeWidgetItem parent,
                       QTreeWidgetItem after,
                       int type)
Constructs a tree widget item of the specified type and inserts it into the given parent after the preceding item.

See also:
type().


QTreeWidgetItem

public QTreeWidgetItem(QTreeWidgetItem parent,
                       java.util.List strings)
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:
type().


QTreeWidgetItem

public QTreeWidgetItem(QTreeWidgetItem parent,
                       java.util.List strings,
                       int type)
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:
type().


QTreeWidgetItem

public QTreeWidgetItem(QTreeWidgetItem parent)
Constructs a tree widget item and append it to the given parent.

See also:
type().


QTreeWidgetItem

public QTreeWidgetItem(QTreeWidgetItem parent,
                       int type)
Constructs a tree widget item of the specified type and appends it to the items in the given parent.

See also:
type().


QTreeWidgetItem

public QTreeWidgetItem(java.util.List strings)
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:
type().


QTreeWidgetItem

public QTreeWidgetItem(java.util.List strings,
                       int type)
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:
type().


QTreeWidgetItem

public QTreeWidgetItem()
Constructs a tree widget item of the specified type. The item must be inserted into a tree widget.

See also:
type().


QTreeWidgetItem

public QTreeWidgetItem(int type)
Constructs a tree widget item of the specified type. The item must be inserted into a tree widget.

See also:
type().

Method Detail

addChild

public final void addChild(QTreeWidgetItem child)
Appends the child item to the list of children.

See also:
insertChild(), and takeChild().


addChildren

public final void addChildren(java.util.List children)
Appends the given list of children to the item.

See also:
insertChildren(), and takeChildren().


background

public final QBrush background(int column)
Returns the brush used to render the background of the specified column.

See also:
setBackground(), and foreground().


checkState

public final Qt.CheckState checkState(int column)
Returns the check state of the label in the given column.

See also:
setCheckState(), and Qt::CheckState .


child

public final QTreeWidgetItem child(int index)
Returns the item at the given index in the list of the item's children.

See also:
parent().


childCount

public final int childCount()
Returns the number of child items.


childIndicatorPolicy

public final QTreeWidgetItem.ChildIndicatorPolicy childIndicatorPolicy()
Returns the item indicator policy. This policy decides when the tree branch expand/collapse indicator is shown.

See also:
setChildIndicatorPolicy().


columnCount

public final int columnCount()
Returns the number of columns in the item.


emitDataChanged

protected final void emitDataChanged()
Causes the model associated with this item to emit a dataChanged () signal for this item.

You normally only need to call this function if you have subclassed QTreeWidgetItem and reimplemented data() and/or setData().

See also:
setData().


flags

public final Qt.ItemFlags flags()
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 .

See also:
setFlags().


font

public final QFont font(int column)
Returns the font used to render the text in the specified column.

See also:
setFont().


foreground

public final QBrush foreground(int column)
Returns the brush used to render the foreground (e. . text) of the specified column.

See also:
setForeground(), and background().


icon

public final QIcon icon(int column)
Returns the icon that is displayed in the specified column.

See also:
setIcon(), and iconSize.


indexOfChild

public final int indexOfChild(QTreeWidgetItem child)
Returns the index of the given child in the item's list of children.


insertChild

public final void insertChild(int index,
                              QTreeWidgetItem child)
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.


insertChildren

public final void insertChildren(int index,
                                 java.util.List children)
Inserts the given list of children into the list of the item children at index .

Children that have already been inserted somewhere else wont be inserted.


isDisabled

public final boolean isDisabled()
Returns true if the item is disabled; otherwise returns false.

See also:
setFlags().


isExpanded

public final boolean isExpanded()
Returns true if the item is expanded, otherwise returns false.

See also:
setExpanded().


isFirstColumnSpanned

public final boolean isFirstColumnSpanned()
Returns true if the item is spanning all the columns in a row; otherwise returns false.

See also:
setFirstColumnSpanned().


isHidden

public final boolean isHidden()
Returns true if the item is hidden, otherwise returns false.

See also:
setHidden().


isSelected

public final boolean isSelected()
Returns true if the item is selected, otherwise returns false.

See also:
setSelected().


writeTo

public final void writeTo(QDataStream out)
Writes thisQTreeWidgetItem


readFrom

public final void readFrom(QDataStream in)
Reads a QTreeWidgetItem


parent

public final QTreeWidgetItem parent()
Returns the item's parent.

See also:
child().


removeChild

public final void removeChild(QTreeWidgetItem child)
Removes the given item indicated by child. The removed item will not be deleted.


setBackground

public final void setBackground(int column,
                                QBrush brush)
Sets the background brush of the label in the given column to the specified brush.

See also:
background(), and setForeground().


setCheckState

public final void setCheckState(int column,
                                Qt.CheckState state)
Sets the item in the given column check state to be state.

See also:
checkState().


setChildIndicatorPolicy

public final void setChildIndicatorPolicy(QTreeWidgetItem.ChildIndicatorPolicy policy)
Sets the item indicator policy. This policy decides when the tree branch expand/collapse indicator is shown. The default value is ShowForChildren.

See also:
childIndicatorPolicy().


setDisabled

public final void setDisabled(boolean disabled)
Disables the item if disabled is true; otherwise enables the item.

See also:
isDisabled(), and setFlags().


setExpanded

public final void setExpanded(boolean expand)
Expands the item if expand is true, otherwise collapses the item.

Warning: The QTreeWidgetItem must be added to the QTreeWidget before calling this function.

See also:
isExpanded().


setFirstColumnSpanned

public final void setFirstColumnSpanned(boolean span)
Sets the first section to span all columns if span is true; otherwise all item sections are shown.

See also:
isFirstColumnSpanned().


setFlags

public final void setFlags(Qt.ItemFlag[] flags)
This is an overloaded method provided for convenience.


setFlags

public final void setFlags(Qt.ItemFlags flags)
Sets the flags for the item to the given flags. These determine whether the item can be selected or modified. This is often used to disable an item.

See also:
flags().


setFont

public final void setFont(int column,
                          QFont font)
Sets the font used to display the text in the given column to the given font.

See also:
font(), setText(), and setForeground().


setForeground

public final void setForeground(int column,
                                QBrush brush)
Sets the foreground brush of the label in the given column to the specified brush.

See also:
foreground(), and setBackground().


setHidden

public final void setHidden(boolean hide)
Hides the item if hide is true, otherwise shows the item.

See also:
isHidden().


setIcon

public final void setIcon(int column,
                          QIcon icon)
Sets the icon to be displayed in the given column to icon.

See also:
icon(), setText(), and iconSize.


setSelected

public final void setSelected(boolean select)
Sets the selected state of the item to select.

See also:
isSelected().


setSizeHint

public final void setSizeHint(int column,
                              QSize size)
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.

See also:
sizeHint().


setStatusTip

public final void setStatusTip(int column,
                               java.lang.String statusTip)
Sets the status tip for the given column to the given statusTip. QTreeWidget mouse tracking needs to be enabled for this feature to work.

See also:
statusTip(), setToolTip(), and setWhatsThis().


setText

public final void setText(int column,
                          java.lang.String text)
Sets the text to be displayed in the given column to the given text.

See also:
text(), setFont(), and setForeground().


setTextAlignment

public final void setTextAlignment(int column,
                                   int alignment)
Sets the text alignment for the label in the given column to the alignment specified (see Qt::AlignmentFlag ).

See also:
textAlignment().


setToolTip

public final void setToolTip(int column,
                             java.lang.String toolTip)
Sets the tooltip for the given column to toolTip.

See also:
toolTip(), setStatusTip(), and setWhatsThis().


setWhatsThis

public final void setWhatsThis(int column,
                               java.lang.String whatsThis)
Sets the "What's This?" help for the given column to whatsThis.

See also:
whatsThis(), setStatusTip(), and setToolTip().


sizeHint

public final QSize sizeHint(int column)
Returns the size hint set for the tree item in the given column (see QSize).

See also:
setSizeHint().


sortChildren

public final void sortChildren(int column,
                               Qt.SortOrder order)
Sorts the children of the item using the given order, by the values in the given column.

Note: This function does nothing if the item is not associated with a QTreeWidget.


statusTip

public final java.lang.String statusTip(int column)
Returns the status tip for the contents of the given column.

See also:
setStatusTip().


takeChild

public final QTreeWidgetItem takeChild(int index)
Removes the item at index and returns it, otherwise return 0.


takeChildren

public final java.util.List takeChildren()
Removes the list of children and returns it, otherwise returns an empty list.


text

public final java.lang.String text(int column)
Returns the text in the specified column.

See also:
setText().


textAlignment

public final int textAlignment(int column)
Returns the text alignment for the label in the given column (see Qt::AlignmentFlag ).

See also:
setTextAlignment().


toolTip

public final java.lang.String toolTip(int column)
Returns the tool tip for the given column.

See also:
setToolTip().


treeWidget

public final QTreeWidget treeWidget()
Returns the tree widget that contains the item.


type

public final int type()
Returns the type passed to the QTreeWidgetItem constructor.


whatsThis

public final java.lang.String whatsThis(int column)
Returns the "What's This?" help for the contents of the given column.

See also:
setWhatsThis().


clone

public QTreeWidgetItem clone()
This method is reimplemented for internal reasons

Overrides:
clone in class java.lang.Object

data

public java.lang.Object data(int column,
                             int role)
Returns the value for the item's column and role.

See also:
setData().


operator_less

public boolean operator_less(QTreeWidgetItem other)
Returns true if the text in the item is less than the text in the other item, otherwise returns false.


read

public void read(QDataStream in)
Reads the item from stream in. This only reads data into a single item.

See also:
write().


setData

public void setData(int column,
                    int role,
                    java.lang.Object value)
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:
data().


write

public void write(QDataStream out)
Writes the item to stream out. This only writes data from one single item.

See also:
read().