|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.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.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
.
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.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. |
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)
|
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?" 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)
|
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 |
---|
public QTreeWidgetItem(QTreeWidget view, QTreeWidgetItem after)
public QTreeWidgetItem(QTreeWidget view, QTreeWidgetItem after, int type)
public QTreeWidgetItem(QTreeWidget view, java.util.List strings)
public QTreeWidgetItem(QTreeWidget view, java.util.List strings, int type)
public QTreeWidgetItem(QTreeWidget view)
type()
.
public QTreeWidgetItem(QTreeWidget view, int type)
public QTreeWidgetItem(QTreeWidgetItem parent, QTreeWidgetItem after)
type()
.
public QTreeWidgetItem(QTreeWidgetItem parent, QTreeWidgetItem after, int type)
type()
.
public QTreeWidgetItem(QTreeWidgetItem parent, java.util.List strings)
type()
.
public QTreeWidgetItem(QTreeWidgetItem parent, java.util.List strings, int type)
type()
.
public QTreeWidgetItem(QTreeWidgetItem parent)
type()
.
public QTreeWidgetItem(QTreeWidgetItem parent, int type)
type()
.
public QTreeWidgetItem(java.util.List strings)
type()
.
public QTreeWidgetItem(java.util.List strings, int type)
type()
.
public QTreeWidgetItem()
type()
.
public QTreeWidgetItem(int type)
type()
.
Method Detail |
---|
public final void addChild(QTreeWidgetItem child)
insertChild()
, and takeChild()
.
public final void addChildren(java.util.List children)
insertChildren()
, and takeChildren()
.
public final QBrush background(int column)
setBackground()
, and foreground()
.
public final Qt.CheckState checkState(int column)
setCheckState()
, and Qt::CheckState
.
public final QTreeWidgetItem child(int index)
parent()
.
public final int childCount()
public final QTreeWidgetItem.ChildIndicatorPolicy childIndicatorPolicy()
setChildIndicatorPolicy()
.
public final int columnCount()
public final Qt.ItemFlags flags()
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
.
setFlags()
.
public final QFont font(int column)
setFont()
.
public final QBrush foreground(int column)
setForeground()
, and background()
.
public final QIcon icon(int column)
setIcon()
, and iconSize
.
public final int indexOfChild(QTreeWidgetItem child)
public final void insertChild(int index, QTreeWidgetItem child)
If the child has already been inserted somewhere else it wont be inserted again.
public final void insertChildren(int index, java.util.List children)
Children that have already been inserted somewhere else wont be inserted.
public final boolean isDisabled()
setFlags()
.
public final boolean isExpanded()
setExpanded()
.
public final boolean isFirstColumnSpanned()
setFirstColumnSpanned()
.
public final boolean isHidden()
setHidden()
.
public final boolean isSelected()
setSelected()
.
public final void writeTo(QDataStream out)
public final void readFrom(QDataStream in)
public final QTreeWidgetItem parent()
child()
.
public final void removeChild(QTreeWidgetItem child)
public final void setBackground(int column, QBrush brush)
background()
, and setForeground()
.
public final void setCheckState(int column, Qt.CheckState state)
checkState()
.
public final void setChildIndicatorPolicy(QTreeWidgetItem.ChildIndicatorPolicy policy)
childIndicatorPolicy()
.
public final void setDisabled(boolean disabled)
isDisabled()
, and setFlags()
.
public final void setExpanded(boolean expand)
Warning: The QTreeWidgetItem
must be added to the QTreeWidget
before calling this function.
isExpanded()
.
public final void setFirstColumnSpanned(boolean span)
isFirstColumnSpanned()
.
public final void setFlags(Qt.ItemFlag[] flags)
flags()
.
public final void setFlags(Qt.ItemFlags flags)
flags()
.
public final void setFont(int column, QFont font)
font()
, setText()
, and setForeground()
.
public final void setForeground(int column, QBrush brush)
foreground()
, and setBackground()
.
public final void setHidden(boolean hide)
isHidden()
.
public final void setIcon(int column, QIcon icon)
icon()
, setText()
, and iconSize
.
public final void setSelected(boolean select)
isSelected()
.
public final void setSizeHint(int column, QSize size)
sizeHint()
.
public final void setStatusTip(int column, java.lang.String statusTip)
QTreeWidget
mouse tracking needs to be enabled for this feature to work. statusTip()
, setToolTip()
, and setWhatsThis()
.
public final void setText(int column, java.lang.String text)
text()
, setFont()
, and setForeground()
.
public final void setTextAlignment(int column, int alignment)
Qt::AlignmentFlag
). textAlignment()
.
public final void setToolTip(int column, java.lang.String toolTip)
toolTip()
, setStatusTip()
, and setWhatsThis()
.
public final void setWhatsThis(int column, java.lang.String whatsThis)
whatsThis()
, setStatusTip()
, and setToolTip()
.
public final QSize sizeHint(int column)
QSize
). setSizeHint()
.
public final void sortChildren(int column, Qt.SortOrder order)
Note: This function does nothing if the item is not associated with a QTreeWidget
.
public final java.lang.String statusTip(int column)
setStatusTip()
.
public final QTreeWidgetItem takeChild(int index)
public final java.util.List takeChildren()
public final java.lang.String text(int column)
setText()
.
public final int textAlignment(int column)
Qt::AlignmentFlag
). setTextAlignment()
.
public final java.lang.String toolTip(int column)
setToolTip()
.
public final QTreeWidget treeWidget()
public final int type()
QTreeWidgetItem
constructor.
public final java.lang.String whatsThis(int column)
setWhatsThis()
.
public QTreeWidgetItem clone()
clone
in class java.lang.Object
public java.lang.Object data(int column, int role)
setData()
.
public boolean operator_less(QTreeWidgetItem other)
public void read(QDataStream in)
write()
.
public void setData(int column, int role, java.lang.Object value)
The role describes the type of data specified by value, and is defined by the Qt::ItemDataRole
enum.
data()
.
public void write(QDataStream out)
read()
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |