|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.gui.QTreeWidgetItem
public class QTreeWidgetItem
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.
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.
Nested Class Summary | |
---|---|
static class |
QTreeWidgetItem.ChildIndicatorPolicy
Press link for info on 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.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Constructor Summary | |
---|---|
QTreeWidgetItem()
Equivalent to QTreeWidgetItem(Type). |
|
QTreeWidgetItem(int type)
Constructs a tree widget item of the specified type. |
|
QTreeWidgetItem(java.util.List<java.lang.String> strings)
Equivalent to QTreeWidgetItem(strings, Type). |
|
QTreeWidgetItem(java.util.List<java.lang.String> strings,
int type)
Constructs a tree widget item of the specified type. |
|
QTreeWidgetItem(QTreeWidget view)
Equivalent to QTreeWidgetItem(view, Type). |
|
QTreeWidgetItem(QTreeWidget view,
int type)
Constructs a tree widget item of the specified type and appends it to the items in the given view. |
|
QTreeWidgetItem(QTreeWidgetItem parent)
Equivalent to QTreeWidgetItem(parent, Type). |
|
QTreeWidgetItem(QTreeWidgetItem parent,
int type)
Constructs a tree widget item and append it to the given parent. |
|
QTreeWidgetItem(QTreeWidgetItem parent,
java.util.List<java.lang.String> strings)
Equivalent to QTreeWidgetItem(parent, strings, Type). |
|
QTreeWidgetItem(QTreeWidgetItem parent,
java.util.List<java.lang.String> strings,
int type)
Constructs a tree widget item and append it to the given parent. |
|
QTreeWidgetItem(QTreeWidgetItem parent,
QTreeWidgetItem after)
Equivalent to QTreeWidgetItem(parent, after, Type). |
|
QTreeWidgetItem(QTreeWidgetItem parent,
QTreeWidgetItem after,
int type)
Constructs a tree widget item of the specified type that is inserted into the parent after the after child item. |
|
QTreeWidgetItem(QTreeWidget view,
java.util.List<java.lang.String> strings)
Equivalent to QTreeWidgetItem(view, strings, Type). |
|
QTreeWidgetItem(QTreeWidget view,
java.util.List<java.lang.String> strings,
int type)
Constructs a tree widget item of the specified type and appends it to the items in the given view. |
|
QTreeWidgetItem(QTreeWidget view,
QTreeWidgetItem after)
Equivalent to QTreeWidgetItem(view, after, Type). |
|
QTreeWidgetItem(QTreeWidget view,
QTreeWidgetItem after,
int type)
Constructs a tree widget item of the specified type and inserts it into the given view after the after item. |
Method Summary | |
---|---|
void |
addChild(QTreeWidgetItem child)
Appends the child item to the list of children. |
void |
addChildren(java.util.List<QTreeWidgetItem> 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()
Creates a deep copy of the item and of its children. |
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. |
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.g. text) of the specified column. |
static QTreeWidgetItem |
fromNativePointer(QNativePointer nativePointer)
This function returns the QTreeWidgetItem instance pointed to by nativePointer |
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<QTreeWidgetItem> 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. |
QTreeWidgetItem |
parent()
Returns the item's parent. |
void |
read(QDataStream in)
Reads the item from stream in. |
void |
readFrom(QDataStream in)
Reads a QTreeWidgetItem from in. |
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)
Sets the flags for the item to the given flags. |
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? |
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<QTreeWidgetItem> |
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? |
void |
write(QDataStream out)
Writes the item to stream out. |
void |
writeTo(QDataStream out)
Writes thisQTreeWidgetItem to out. |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QTreeWidgetItem(java.util.List<java.lang.String> strings)
Equivalent to QTreeWidgetItem(strings, Type).
public QTreeWidgetItem(java.util.List<java.lang.String> 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.
public QTreeWidgetItem(QTreeWidget view, java.util.List<java.lang.String> strings)
Equivalent to QTreeWidgetItem(view, strings, Type).
public QTreeWidgetItem(QTreeWidget view, java.util.List<java.lang.String> strings, int type)
Constructs a tree widget item of the specified type and appends it to the items in the given view. The given list of strings will be set as the item text for each column in the item.
public QTreeWidgetItem(QTreeWidgetItem parent, java.util.List<java.lang.String> strings)
Equivalent to QTreeWidgetItem(parent, strings, Type).
public QTreeWidgetItem(QTreeWidgetItem parent, java.util.List<java.lang.String> strings, int type)
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.
public QTreeWidgetItem(QTreeWidget view, QTreeWidgetItem after)
Equivalent to QTreeWidgetItem(view, after, Type).
public QTreeWidgetItem(QTreeWidget view, QTreeWidgetItem after, int type)
Constructs a tree widget item of the specified type and inserts it into the given view after the after item.
public QTreeWidgetItem(QTreeWidgetItem parent, QTreeWidgetItem after)
Equivalent to QTreeWidgetItem(parent, after, Type).
public QTreeWidgetItem(QTreeWidgetItem parent, QTreeWidgetItem after, int type)
Constructs a tree widget item of the specified type that is inserted into the parent after the after child item.
public QTreeWidgetItem()
Equivalent to QTreeWidgetItem(Type).
public QTreeWidgetItem(int type)
Constructs a tree widget item of the specified type. The item must be inserted into a tree widget.
public QTreeWidgetItem(QTreeWidgetItem parent)
Equivalent to QTreeWidgetItem(parent, Type).
public QTreeWidgetItem(QTreeWidgetItem parent, int type)
Constructs a tree widget item and append it to the given parent.
public QTreeWidgetItem(QTreeWidget view)
Equivalent to QTreeWidgetItem(view, Type).
public QTreeWidgetItem(QTreeWidget view, int type)
Constructs a tree widget item of the specified type and appends it to the items in the given view.
Method Detail |
---|
public final void addChild(QTreeWidgetItem child)
Appends the child item to the list of children.
public final void addChildren(java.util.List<QTreeWidgetItem> children)
Appends the given list of children to the item.
public final QBrush background(int column)
Returns the brush used to render the background of the specified column.
public final Qt.CheckState checkState(int column)
Returns the check state of the label in the given column.
public final QTreeWidgetItem child(int index)
Returns the item at the given index in the list of the item's children.
public final int childCount()
Returns the number of child items.
public final QTreeWidgetItem.ChildIndicatorPolicy childIndicatorPolicy()
Returns the item indicator policy. This policy decides when the tree branch expand/collapse indicator is shown.
public final int columnCount()
Returns the number of columns in the item.
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.
public final QFont font(int column)
Returns the font used to render the text in the specified column.
public final QBrush foreground(int column)
Returns the brush used to render the foreground (e.g. text) of the specified column.
public final QIcon icon(int column)
Returns the icon that is displayed in the specified column.
public final int indexOfChild(QTreeWidgetItem child)
Returns the index of the given child in the item's list of children.
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.
public final void insertChildren(int index, java.util.List<QTreeWidgetItem> 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.
public final boolean isDisabled()
Returns true if the item is disabled; otherwise returns false.
public final boolean isExpanded()
Returns true if the item is expanded, otherwise returns false.
public final boolean isFirstColumnSpanned()
Returns true if the item is spanning all the columns in a row; otherwise returns false.
public final boolean isHidden()
Returns true if the item is hidden, otherwise returns false.
public final boolean isSelected()
Returns true if the item is selected, otherwise returns false.
public final void writeTo(QDataStream out)
public final void readFrom(QDataStream in)
public final QTreeWidgetItem parent()
Returns the item's parent.
public final void removeChild(QTreeWidgetItem child)
Removes the given item indicated by child. The removed item will not be deleted.
public final void setBackground(int column, QBrush brush)
Sets the background brush of the label in the given column to the specified brush.
public final void setCheckState(int column, Qt.CheckState state)
Sets the item in the given column check state to be state.
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.
public final void setDisabled(boolean disabled)
Disables the item if disabled is true; otherwise enables the item.
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.
public final void setFirstColumnSpanned(boolean span)
Sets the first section to span all columns if span is true; otherwise all item sections are shown.
public final void setFlags(Qt.ItemFlag... 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.
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.
public final void setFont(int column, QFont font)
Sets the font used to display the text in the given column to the given font.
public final void setForeground(int column, QBrush brush)
Sets the foreground brush of the label in the given column to the specified brush.
public final void setHidden(boolean hide)
Hides the item if hide is true, otherwise shows the item.
public final void setIcon(int column, QIcon icon)
Sets the icon to be displayed in the given column to icon.
public final void setSelected(boolean select)
Sets the selected state of the item to select.
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.
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.
public final void setText(int column, java.lang.String text)
Sets the text to be displayed in the given column to the given text.
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).
public final void setToolTip(int column, java.lang.String toolTip)
Sets the tooltip for the given column to toolTip.
public final void setWhatsThis(int column, java.lang.String whatsThis)
Sets the "What's This?" help for the given column to whatsThis.
public final QSize sizeHint(int column)
Returns the size hint set for the tree item in the given column (see QSize).
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.
public final java.lang.String statusTip(int column)
Returns the status tip for the contents of the given column.
public final QTreeWidgetItem takeChild(int index)
Removes the item at index and returns it, otherwise return 0.
public final java.util.List<QTreeWidgetItem> takeChildren()
Removes the list of children and returns it, otherwise returns an empty list.
public final java.lang.String text(int column)
Returns the text in the specified column.
public final int textAlignment(int column)
Returns the text alignment for the label in the given column (see Qt::AlignmentFlag).
public final java.lang.String toolTip(int column)
Returns the tool tip for the given column.
public final QTreeWidget treeWidget()
Returns the tree widget that contains the item.
public final int type()
Returns the type passed to the QTreeWidgetItem constructor.
public final java.lang.String whatsThis(int column)
Returns the "What's This?" help for the contents of the given column.
public QTreeWidgetItem clone()
Creates a deep copy of the item and of its children.
clone
in class java.lang.Object
public java.lang.Object data(int column, int role)
Returns the value for the item's column and role.
public void read(QDataStream in)
Reads the item from stream in. This only reads data into a single item.
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.
public void write(QDataStream out)
Writes the item to stream out. This only writes data from one single item.
public static QTreeWidgetItem fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |