Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QTreeWidgetItem Class Reference

The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class. More...

#include <qtreewidget.h>

+ Collaboration diagram for QTreeWidgetItem:

Public Types

enum  ItemType { Type = 0 , UserType = 1000 }
 This enum describes the types that are used to describe tree widget items. More...
 
enum  ChildIndicatorPolicy { ShowIndicator , DontShowIndicator , DontShowIndicatorWhenChildless }
 

Public Member Functions

 QTreeWidgetItem (int type=Type)
 Constructs a tree widget item of the specified type.
 
 QTreeWidgetItem (const QStringList &strings, int type=Type)
 Constructs a tree widget item of the specified type.
 
 QTreeWidgetItem (QTreeWidget *treeview, int type=Type)
 Constructs a tree widget item of the specified type and appends it to the items in the given parent.
 
 QTreeWidgetItem (QTreeWidget *treeview, const QStringList &strings, int type=Type)
 Constructs a tree widget item of the specified type and appends it to the items in the given parent.
 
 QTreeWidgetItem (QTreeWidget *treeview, QTreeWidgetItem *after, int type=Type)
 Constructs a tree widget item of the specified type and inserts it into the given parent after the preceding item.
 
 QTreeWidgetItem (QTreeWidgetItem *parent, int type=Type)
 Constructs a tree widget item and append it to the given parent.
 
 QTreeWidgetItem (QTreeWidgetItem *parent, const QStringList &strings, int type=Type)
 Constructs a tree widget item and append it to the given parent.
 
 QTreeWidgetItem (QTreeWidgetItem *parent, QTreeWidgetItem *after, int type=Type)
 Constructs a tree widget item of the specified type that is inserted into the parent after the preceding child item.
 
 QTreeWidgetItem (const QTreeWidgetItem &other)
 
virtual ~QTreeWidgetItem ()
 Destroys this tree widget item.
 
virtual QTreeWidgetItemclone () const
 Creates a deep copy of the item and of its children.
 
QTreeWidgettreeWidget () const
 Returns the tree widget that contains the item.
 
void setSelected (bool select)
 
bool isSelected () const
 
void setHidden (bool hide)
 
bool isHidden () const
 
void setExpanded (bool expand)
 
bool isExpanded () const
 
void setFirstColumnSpanned (bool span)
 
bool isFirstColumnSpanned () const
 
void setDisabled (bool disabled)
 
bool isDisabled () const
 
void setChildIndicatorPolicy (QTreeWidgetItem::ChildIndicatorPolicy policy)
 Sets the item indicator policy.
 
QTreeWidgetItem::ChildIndicatorPolicy childIndicatorPolicy () const
 Returns the item indicator policy.
 
Qt::ItemFlags flags () const
 Returns the flags used to describe the item.
 
void setFlags (Qt::ItemFlags flags)
 Sets the flags for the item to the given flags.
 
QString text (int column) const
 Returns the text in the specified column.
 
void setText (int column, const QString &text)
 Sets the text to be displayed in the given column to the given text.
 
QIcon icon (int column) const
 Returns the icon that is displayed in the specified column.
 
void setIcon (int column, const QIcon &icon)
 Sets the icon to be displayed in the given column to icon.
 
QString statusTip (int column) const
 Returns the status tip for the contents of the given column.
 
void setStatusTip (int column, const QString &statusTip)
 Sets the status tip for the given column to the given statusTip.
 
QFont font (int column) const
 Returns the font used to render the text in the specified column.
 
void setFont (int column, const QFont &font)
 Sets the font used to display the text in the given column to the given font.
 
Qt::Alignment textAlignment (int column) const
 
void setTextAlignment (int column, Qt::Alignment alignment)
 \obsolete [6.4] Use the overload that takes a Qt::Alignment argument.
 
QBrush background (int column) const
 
void setBackground (int column, const QBrush &brush)
 
QBrush foreground (int column) const
 
void setForeground (int column, const QBrush &brush)
 
Qt::CheckState checkState (int column) const
 Returns the check state of the label in the given column.
 
void setCheckState (int column, Qt::CheckState state)
 Sets the item in the given column check state to be state.
 
QSize sizeHint (int column) const
 
void setSizeHint (int column, const QSize &size)
 
virtual QVariant data (int column, int role) const
 Returns the value for the item's column and role.
 
virtual void setData (int column, int role, const QVariant &value)
 Sets the value for the item's column and role to the given value.
 
virtual bool operator< (const QTreeWidgetItem &other) const
 Returns true if the text in the item is less than the text in the other item, otherwise returns false.
 
virtual void read (QDataStream &in)
 Reads the item from stream in.
 
virtual void write (QDataStream &out) const
 Writes the item to stream out.
 
QTreeWidgetItemoperator= (const QTreeWidgetItem &other)
 Assigns other's data and flags to this item.
 
QTreeWidgetItemparent () const
 Returns the item's parent.
 
QTreeWidgetItemchild (int index) const
 Returns the item at the given index in the list of the item's children.
 
int childCount () const
 Returns the number of child items.
 
int columnCount () const
 Returns the number of columns in the item.
 
int indexOfChild (QTreeWidgetItem *child) const
 Returns the index of the given child in the item's list of children.
 
void addChild (QTreeWidgetItem *child)
 Appends the child item to the list of children.
 
void insertChild (int index, QTreeWidgetItem *child)
 Inserts the child item at index in the list of children.
 
void removeChild (QTreeWidgetItem *child)
 Removes the given item indicated by child.
 
QTreeWidgetItemtakeChild (int index)
 Removes the item at index and returns it, otherwise return 0.
 
void addChildren (const QList< QTreeWidgetItem * > &children)
 
void insertChildren (int index, const QList< QTreeWidgetItem * > &children)
 
QList< QTreeWidgetItem * > takeChildren ()
 
int type () const
 Returns the type passed to the QTreeWidgetItem constructor.
 
void sortChildren (int column, Qt::SortOrder order)
 

Protected Member Functions

void emitDataChanged ()
 

Friends

class QTreeModel
 
class QTreeWidget
 
class QTreeWidgetPrivate
 
class QTreeWidgetItemIterator
 
class QTreeWidgetItemPrivate
 

Related Symbols

(Note that these are not member symbols.)

QDataStreamoperator<< (QDataStream &out, const QTreeWidgetItem &item)
 Writes the tree widget item item to stream out.
 
QDataStreamoperator>> (QDataStream &in, QTreeWidgetItem &item)
 Reads a tree widget item from stream in into item.
 

Detailed Description

The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class.

\inmodule QtWidgets

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:

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 \l{Qt::ItemFlags}). Checkable items can be checked and unchecked with the setCheckState() function. The corresponding checkState() function indicates whether the item is currently checked.

Definition at line 22 of file qtreewidget.h.

Member Enumeration Documentation

◆ ChildIndicatorPolicy

Since
4.3

\value ShowIndicator The controls for expanding and collapsing will be shown for this item even if there are no children. \value 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. \value DontShowIndicatorWhenChildless The controls for expanding and collapsing will be shown if the item contains children.

Enumerator
ShowIndicator 
DontShowIndicator 
DontShowIndicatorWhenChildless 

Definition at line 61 of file qtreewidget.h.

◆ ItemType

This enum describes the types that are used to describe tree widget items.

\value Type The default type for tree widget items. \value UserType The minimum value for custom types. Values below UserType are reserved by Qt.

You can define new user types in QTreeWidgetItem subclasses to ensure that custom items are treated specially; for example, when items are sorted.

See also
type()
Enumerator
Type 
UserType 

Definition at line 30 of file qtreewidget.h.

Constructor & Destructor Documentation

◆ QTreeWidgetItem() [1/9]

QTreeWidgetItem::QTreeWidgetItem ( int type = Type)
explicit

Constructs a tree widget item of the specified type.

The item must be inserted into a tree widget.

See also
type()

Definition at line 1385 of file qtreewidget.cpp.

Referenced by clone().

+ Here is the caller graph for this function:

◆ QTreeWidgetItem() [2/9]

QTreeWidgetItem::QTreeWidgetItem ( const QStringList & strings,
int type = Type )
explicit

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()

Definition at line 1395 of file qtreewidget.cpp.

References i, and setText().

+ Here is the call graph for this function:

◆ QTreeWidgetItem() [3/9]

QTreeWidgetItem::QTreeWidgetItem ( QTreeWidget * parent,
int type = Type )
explicit

Constructs a tree widget item of the specified type and appends it to the items in the given parent.

See also
type()

Definition at line 1411 of file qtreewidget.cpp.

References QSqlQueryModel::columnCount(), and model.

+ Here is the call graph for this function:

◆ QTreeWidgetItem() [4/9]

QTreeWidgetItem::QTreeWidgetItem ( QTreeWidget * parent,
const QStringList & strings,
int type = 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()

Definition at line 1431 of file qtreewidget.cpp.

References QSqlQueryModel::columnCount(), i, model, and setText().

+ Here is the call graph for this function:

◆ QTreeWidgetItem() [5/9]

QTreeWidgetItem::QTreeWidgetItem ( QTreeWidget * parent,
QTreeWidgetItem * preceding,
int type = Type )

Constructs a tree widget item of the specified type and inserts it into the given parent after the preceding item.

See also
type()

Definition at line 1451 of file qtreewidget.cpp.

References QObject::children(), QSqlQueryModel::columnCount(), i, QListSpecialMethodsBase< T >::indexOf(), and model.

+ Here is the call graph for this function:

◆ QTreeWidgetItem() [6/9]

QTreeWidgetItem::QTreeWidgetItem ( QTreeWidgetItem * parent,
int type = Type )
explicit

Constructs a tree widget item and append it to the given parent.

See also
type()

Definition at line 1467 of file qtreewidget.cpp.

References addChild(), and parent().

+ Here is the call graph for this function:

◆ QTreeWidgetItem() [7/9]

QTreeWidgetItem::QTreeWidgetItem ( QTreeWidgetItem * parent,
const QStringList & strings,
int type = 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.

See also
type()

Definition at line 1480 of file qtreewidget.cpp.

References addChild(), i, parent(), and setText().

+ Here is the call graph for this function:

◆ QTreeWidgetItem() [8/9]

QTreeWidgetItem::QTreeWidgetItem ( QTreeWidgetItem * parent,
QTreeWidgetItem * preceding,
int type = Type )

Constructs a tree widget item of the specified type that is inserted into the parent after the preceding child item.

See also
type()

Definition at line 1497 of file qtreewidget.cpp.

References i, QListSpecialMethodsBase< T >::indexOf(), insertChild(), and parent().

+ Here is the call graph for this function:

◆ QTreeWidgetItem() [9/9]

QTreeWidgetItem::QTreeWidgetItem ( const QTreeWidgetItem & other)
Since
4.1

Constructs a copy of other. Note that type() and treeWidget() are not copied.

This function is useful when reimplementing clone().

See also
data(), flags()

Definition at line 1907 of file qtreewidget.cpp.

References QTreeWidgetItemPrivate::display, and other().

+ Here is the call graph for this function:

◆ ~QTreeWidgetItem()

QTreeWidgetItem::~QTreeWidgetItem ( )
virtual

Destroys this tree widget item.

The item will be removed from \l{QTreeWidget}s to which it has been added. This makes it safe to delete an item at any time.

Definition at line 1514 of file qtreewidget.cpp.

References QList< T >::at(), child, QObject::children(), QList< T >::clear(), i, QListSpecialMethodsBase< T >::indexOf(), QList< T >::isEmpty(), model, QList< T >::size(), and QList< T >::takeAt().

+ Here is the call graph for this function:

Member Function Documentation

◆ addChild()

void QTreeWidgetItem::addChild ( QTreeWidgetItem * child)

Appends the child item to the list of children.

See also
insertChild(), takeChild()

Definition at line 1938 of file qtreewidget.cpp.

References child, insertChild(), and QList< T >::size().

Referenced by QTreeWidgetItem(), and QTreeWidgetItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addChildren()

void QTreeWidgetItem::addChildren ( const QList< QTreeWidgetItem * > & children)
Since
4.1

Appends the given list of children to the item.

See also
insertChildren(), takeChildren()

Definition at line 2041 of file qtreewidget.cpp.

References insertChildren().

+ Here is the call graph for this function:

◆ background()

QBrush QTreeWidgetItem::background ( int column) const
inline
Since
4.2

Returns the brush used to render the background of the specified column.

See also
foreground()

Definition at line 113 of file qtreewidget.h.

References Qt::BackgroundRole.

◆ checkState()

Qt::CheckState QTreeWidgetItem::checkState ( int column) const
inline

Returns the check state of the label in the given column.

See also
Qt::CheckState

Definition at line 123 of file qtreewidget.h.

References Qt::CheckStateRole.

◆ child()

QTreeWidgetItem * QTreeWidgetItem::child ( int index) const
inline

Returns the item at the given index in the list of the item's children.

See also
parent()

Definition at line 145 of file qtreewidget.h.

Referenced by QTreeModel::index().

+ Here is the caller graph for this function:

◆ childCount()

int QTreeWidgetItem::childCount ( ) const
inline

Returns the number of child items.

Definition at line 151 of file qtreewidget.h.

Referenced by QTreeModel::clear(), QTreeModel::hasChildren(), and QTreeModel::rowCount().

+ Here is the caller graph for this function:

◆ childIndicatorPolicy()

QTreeWidgetItem::ChildIndicatorPolicy QTreeWidgetItem::childIndicatorPolicy ( ) const

Returns the item indicator policy.

This policy decides when the tree branch expand/collapse indicator is shown.

See also
setChildIndicatorPolicy()

Definition at line 1623 of file qtreewidget.cpp.

References QTreeWidgetItemPrivate::policy.

◆ clone()

QTreeWidgetItem * QTreeWidgetItem::clone ( ) const
virtual

Creates a deep copy of the item and of its children.

Definition at line 1562 of file qtreewidget.cpp.

References QTreeWidgetItem(), copy(), i, QList< T >::insert(), item, and parent().

+ Here is the call graph for this function:

◆ columnCount()

int QTreeWidgetItem::columnCount ( ) const
inline

Returns the number of columns in the item.

Definition at line 152 of file qtreewidget.h.

Referenced by QTreeModel::columnCount().

+ Here is the caller graph for this function:

◆ data()

QVariant QTreeWidgetItem::data ( int column,
int role ) const
virtual

Returns the value for the item's column and role.

Definition at line 1820 of file qtreewidget.cpp.

References QList< T >::at(), Qt::CheckStateRole, QTreeWidgetItemPrivate::display, Qt::DisplayRole, Qt::EditRole, Qt::ItemIsAutoTristate, Q_FALLTHROUGH, and QList< T >::size().

Referenced by QTreeModel::data(), QTreeModel::headerData(), and QTreeModel::itemData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ emitDataChanged()

void QTreeWidgetItem::emitDataChanged ( )
protected
Since
4.5

Causes the model associated with this item to emit a \l{QAbstractItemModel::dataChanged()}{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()

Definition at line 2235 of file qtreewidget.cpp.

◆ flags()

Qt::ItemFlags QTreeWidgetItem::flags ( ) const

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 | Qt::ItemIsDropEnabled.

See also
setFlags()

Definition at line 1727 of file qtreewidget.cpp.

Referenced by QTreeModel::flags(), isDisabled(), setDisabled(), and setFlags().

+ Here is the caller graph for this function:

◆ font()

QFont QTreeWidgetItem::font ( int column) const
inline

Returns the font used to render the text in the specified column.

See also
setFont()

Definition at line 92 of file qtreewidget.h.

References Qt::FontRole.

◆ foreground()

QBrush QTreeWidgetItem::foreground ( int column) const
inline
Since
4.2

Returns the brush used to render the foreground (e.g. text) of the specified column. Setting a default-constructed brush will let the view use the default color from the style.

See also
background()

Definition at line 118 of file qtreewidget.h.

References Qt::ForegroundRole.

◆ icon()

QIcon QTreeWidgetItem::icon ( int column) const
inline

Returns the icon that is displayed in the specified column.

See also
setIcon(), {QAbstractItemView::iconSize}{iconSize}

Definition at line 72 of file qtreewidget.h.

References Qt::DecorationRole.

◆ indexOfChild()

int QTreeWidgetItem::indexOfChild ( QTreeWidgetItem * child) const
inline

Returns the index of the given child in the item's list of children.

Definition at line 215 of file qtreewidget.h.

References QListSpecialMethodsBase< T >::indexOf().

+ Here is the call graph for this function:

◆ insertChild()

void QTreeWidgetItem::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 won't be inserted again.

Definition at line 1951 of file qtreewidget.cpp.

References child, QSqlQueryModel::columnCount(), i, QList< T >::insert(), QTreeView::isSortingEnabled(), model, QTreeWidgetItemPrivate::propagateDisabled(), QList< T >::size(), and QTreeWidgetItemPrivate::updateHiddenStatus().

Referenced by QTreeWidgetItem(), addChild(), and insertChildren().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertChildren()

void QTreeWidgetItem::insertChildren ( int index,
const QList< QTreeWidgetItem * > & children )
Since
4.1

Inserts the given list of children into the list of the item children at index .

Children that have already been inserted somewhere else won't be inserted.

Definition at line 2053 of file qtreewidget.cpp.

References child, i, insertChild(), QTreeView::isSortingEnabled(), model, QTreeWidgetItemPrivate::propagateDisabled(), and QTreeWidgetItemPrivate::updateHiddenStatus().

Referenced by addChildren().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isDisabled()

bool QTreeWidgetItem::isDisabled ( ) const
inline
Since
4.3

Returns true if the item is disabled; otherwise returns false.

See also
setFlags()

Definition at line 340 of file qtreewidget.h.

References flags(), and Qt::ItemIsEnabled.

+ Here is the call graph for this function:

◆ isExpanded()

bool QTreeWidgetItem::isExpanded ( ) const
Since
4.2

Returns true if the item is expanded, otherwise returns false.

See also
setExpanded()

Definition at line 1077 of file qtreewidget.cpp.

References QTreeView::isExpanded(), and model.

+ Here is the call graph for this function:

◆ isFirstColumnSpanned()

bool QTreeWidgetItem::isFirstColumnSpanned ( ) const
Since
4.3

Returns true if the item is spanning all the columns in a row; otherwise returns false.

See also
setFirstColumnSpanned()

Definition at line 1112 of file qtreewidget.cpp.

References QAbstractTableModel::index(), QTreeView::isFirstColumnSpanned(), and model.

+ Here is the call graph for this function:

◆ isHidden()

bool QTreeWidgetItem::isHidden ( ) const
Since
4.2

Returns true if the item is hidden, otherwise returns false.

See also
setHidden()

Definition at line 1038 of file qtreewidget.cpp.

References QTreeView::header(), QTreeView::isRowHidden(), and model.

+ Here is the call graph for this function:

◆ isSelected()

bool QTreeWidgetItem::isSelected ( ) const
Since
4.2

Returns true if the item is selected, otherwise returns false.

See also
setSelected()

Definition at line 998 of file qtreewidget.cpp.

References QTreeWidgetItemPrivate::selected.

◆ operator<()

bool QTreeWidgetItem::operator< ( const QTreeWidgetItem & other) const
virtual

Returns true if the text in the item is less than the text in the other item, otherwise returns false.

Definition at line 1850 of file qtreewidget.cpp.

References Qt::DisplayRole, other(), QTreeWidget::sortColumn(), and QAbstractItemModelPrivate::variantLessThan().

+ Here is the call graph for this function:

◆ operator=()

QTreeWidgetItem & QTreeWidgetItem::operator= ( const QTreeWidgetItem & other)

Assigns other's data and flags to this item.

Note that type() and treeWidget() are not copied.

This function is useful when reimplementing clone().

See also
data(), flags()

Definition at line 1924 of file qtreewidget.cpp.

References QTreeWidgetItemPrivate::display, other(), and QTreeWidgetItemPrivate::policy.

+ Here is the call graph for this function:

◆ parent()

QTreeWidgetItem * QTreeWidgetItem::parent ( ) const
inline

Returns the item's parent.

See also
child()

Definition at line 144 of file qtreewidget.h.

Referenced by QTreeWidgetItem(), QTreeWidgetItem(), QTreeWidgetItem(), QTreeWidgetItemIterator::QTreeWidgetItemIterator(), clone(), QTreeModel::parent(), and setFlags().

+ Here is the caller graph for this function:

◆ read()

void QTreeWidgetItem::read ( QDataStream & in)
virtual

Reads the item from stream in.

This only reads data into a single item.

See also
write()

Definition at line 1865 of file qtreewidget.cpp.

References QList< T >::at(), QList< T >::clear(), QTreeWidgetItemPrivate::display, Qt::DisplayRole, i, and QVariant::value().

+ Here is the call graph for this function:

◆ removeChild()

void QTreeWidgetItem::removeChild ( QTreeWidgetItem * child)

Removes the given item indicated by child.

The removed item will not be deleted.

Definition at line 1993 of file qtreewidget.cpp.

References child, QListSpecialMethodsBase< T >::indexOf(), takeChild(), and void.

+ Here is the call graph for this function:

◆ setBackground()

void QTreeWidgetItem::setBackground ( int column,
const QBrush & brush )
inline
Since
4.2

Sets the background brush of the label in the given column to the specified brush. Setting a default-constructed brush will let the view use the default color from the style.

Note
If \l{Qt Style Sheets} are used on the same widget as setBackground(), style sheets will take precedence if the settings conflict.
See also
setForeground()

Definition at line 115 of file qtreewidget.h.

References Qt::BackgroundRole, Qt::NoBrush, and setData().

+ Here is the call graph for this function:

◆ setCheckState()

void QTreeWidgetItem::setCheckState ( int column,
Qt::CheckState state )
inline

Sets the item in the given column check state to be state.

See also
checkState()

Definition at line 125 of file qtreewidget.h.

References Qt::CheckStateRole, setData(), and state.

+ Here is the call graph for this function:

◆ setChildIndicatorPolicy()

void QTreeWidgetItem::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 DontShowIndicatorWhenChildless.

See also
childIndicatorPolicy()

Definition at line 1605 of file qtreewidget.cpp.

References policy, QTreeWidgetItemPrivate::policy, and QAbstractItemView::scheduleDelayedItemsLayout().

+ Here is the call graph for this function:

◆ setData()

void QTreeWidgetItem::setData ( int column,
int role,
const QVariant & value )
virtual

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.

Note
The default implementation treats Qt::EditRole and Qt::DisplayRole as referring to the same data.

Definition at line 1742 of file qtreewidget.cpp.

References QList< T >::append(), QList< T >::at(), Qt::CheckStateRole, child, QTreeWidgetItemPrivate::display, Qt::DisplayRole, Qt::EditRole, i, Qt::ItemIsAutoTristate, model, Qt::PartiallyChecked, Q_FALLTHROUGH, and QList< T >::size().

Referenced by QTreeModel::setData(), setFont(), QTreeModel::setHeaderData(), setIcon(), and setText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDisabled()

void QTreeWidgetItem::setDisabled ( bool disabled)
inline
Since
4.3

Disables the item if disabled is true; otherwise enables the item.

See also
setFlags()

Definition at line 337 of file qtreewidget.h.

References disabled, flags(), Qt::ItemIsEnabled, and setFlags().

+ Here is the call graph for this function:

◆ setExpanded()

void QTreeWidgetItem::setExpanded ( bool expand)
Since
4.2

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()

Definition at line 1060 of file qtreewidget.cpp.

References model, and QTreeView::setExpanded().

+ Here is the call graph for this function:

◆ setFirstColumnSpanned()

void QTreeWidgetItem::setFirstColumnSpanned ( bool span)
Since
4.3

Sets the first section to span all columns if span is true; otherwise all item sections are shown.

See also
isFirstColumnSpanned()

Definition at line 1095 of file qtreewidget.cpp.

References QAbstractTableModel::index(), model, and QTreeView::setFirstColumnSpanned().

+ Here is the call graph for this function:

◆ setFlags()

void QTreeWidgetItem::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()

Definition at line 1636 of file qtreewidget.cpp.

References QList< T >::at(), child, QTreeWidgetItemPrivate::disabled, flags(), i, Qt::ItemIsEnabled, parent(), and QList< T >::size().

Referenced by setDisabled().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFont()

void QTreeWidgetItem::setFont ( int column,
const QFont & font )
inline

Sets the font used to display the text in the given column to the given font.

See also
font(), setText(), setForeground()

Definition at line 212 of file qtreewidget.h.

References Qt::FontRole, and setData().

+ Here is the call graph for this function:

◆ setForeground()

void QTreeWidgetItem::setForeground ( int column,
const QBrush & brush )
inline
Since
4.2

Sets the foreground brush of the label in the given column to the specified brush.

See also
setBackground()

Definition at line 120 of file qtreewidget.h.

References Qt::ForegroundRole, Qt::NoBrush, and setData().

+ Here is the call graph for this function:

◆ setHidden()

void QTreeWidgetItem::setHidden ( bool hide)
Since
4.2

Hides the item if hide is true, otherwise shows the item.

Note
A call to this function has no effect if the item is not currently in a view. In particular, calling setHidden(true) on an item and only then adding it to a view will result in a visible item.
See also
isHidden()

Definition at line 1015 of file qtreewidget.cpp.

References QTreeView::header(), QTreeWidgetItemPrivate::hidden, hide(), model, and QTreeView::setRowHidden().

+ Here is the call graph for this function:

◆ setIcon()

void QTreeWidgetItem::setIcon ( int column,
const QIcon & icon )
inline

Sets the icon to be displayed in the given column to icon.

See also
icon(), setText(), {QAbstractItemView::iconSize}{iconSize}

Definition at line 194 of file qtreewidget.h.

References Qt::DecorationRole, and setData().

+ Here is the call graph for this function:

◆ setSelected()

void QTreeWidgetItem::setSelected ( bool select)
Since
4.2

Sets the selected state of the item to select.

See also
isSelected()

Definition at line 978 of file qtreewidget.cpp.

References QItemSelectionModel::Deselect, QAbstractTableModel::index(), model, QItemSelectionModel::Rows, QItemSelectionModel::Select, QItemSelectionModel::select(), select(), QTreeWidgetItemPrivate::selected, and QAbstractItemView::selectionModel().

+ Here is the call graph for this function:

◆ setSizeHint()

void QTreeWidgetItem::setSizeHint ( int column,
const QSize & size )
inline
Since
4.1

Sets the size hint for the tree item in the given column to be size. If no size hint is set or size is invalid, the item delegate will compute the size hint based on the item data.

Definition at line 130 of file qtreewidget.h.

References setData(), and Qt::SizeHintRole.

+ Here is the call graph for this function:

◆ setStatusTip()

void QTreeWidgetItem::setStatusTip ( int column,
const QString & statusTip )
inline

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(), setWhatsThis()

◆ setText()

void QTreeWidgetItem::setText ( int column,
const QString & text )
inline

Sets the text to be displayed in the given column to the given text.

See also
text(), setFont(), setForeground()

Definition at line 191 of file qtreewidget.h.

References Qt::DisplayRole, and setData().

Referenced by QTreeWidgetItem(), QTreeWidgetItem(), and QTreeWidgetItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTextAlignment()

void QTreeWidgetItem::setTextAlignment ( int column,
Qt::Alignment alignment )
inline

\obsolete [6.4] Use the overload that takes a Qt::Alignment argument.

Sets the text alignment for the label in the given column to the alignment specified.

See also
Qt::Alignment
Since
6.4

Sets the text alignment for the label in the given column to the alignment specified.

Definition at line 110 of file qtreewidget.h.

References alignment, QVariant::fromValue(), setData(), and Qt::TextAlignmentRole.

+ Here is the call graph for this function:

◆ sizeHint()

QSize QTreeWidgetItem::sizeHint ( int column) const
inline
Since
4.1

Returns the size hint set for the tree item in the given column (see \l{QSize}).

Definition at line 128 of file qtreewidget.h.

References Qt::SizeHintRole.

◆ sortChildren()

void QTreeWidgetItem::sortChildren ( int column,
Qt::SortOrder order )
inline
Since
4.2

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.

Definition at line 165 of file qtreewidget.h.

Referenced by QTreeModel::sort().

+ Here is the caller graph for this function:

◆ statusTip()

QString QTreeWidgetItem::statusTip ( int column) const
inline

Returns the status tip for the contents of the given column.

See also
setStatusTip()

Definition at line 76 of file qtreewidget.h.

References Qt::StatusTipRole.

◆ takeChild()

QTreeWidgetItem * QTreeWidgetItem::takeChild ( int index)

Removes the item at index and returns it, otherwise return 0.

Definition at line 2001 of file qtreewidget.cpp.

References QList< T >::at(), QSqlQueryModel::endRemoveRows(), i, item, model, QTreeWidgetItemPrivate::propagateDisabled(), QList< T >::size(), QList< T >::takeAt(), and QTreeWidgetItemPrivate::updateHiddenStatus().

Referenced by removeChild(), and QTreeModel::removeRows().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ takeChildren()

QList< QTreeWidgetItem * > QTreeWidgetItem::takeChildren ( )
Since
4.1

Removes the list of children and returns it, otherwise returns an empty list.

Definition at line 2106 of file qtreewidget.cpp.

References QList< T >::at(), QList< T >::clear(), i, item, model, QTreeWidgetItemPrivate::propagateDisabled(), and QList< T >::size().

+ Here is the call graph for this function:

◆ text()

QString QTreeWidgetItem::text ( int column) const
inline

Returns the text in the specified column.

See also
setText()

Definition at line 68 of file qtreewidget.h.

References Qt::DisplayRole.

◆ textAlignment()

int QTreeWidgetItem::textAlignment ( int column) const
inline

Returns the text alignment for the label in the given column.

Note
This function returns an int for historical reasons. It will be corrected to return Qt::Alignment in Qt 7.
See also
Qt::Alignment

Definition at line 100 of file qtreewidget.h.

References Qt::TextAlignmentRole.

◆ treeWidget()

QTreeWidget * QTreeWidgetItem::treeWidget ( ) const
inline

Returns the tree widget that contains the item.

Definition at line 44 of file qtreewidget.h.

References view.

◆ type()

int QTreeWidgetItem::type ( ) const
inline

Returns the type passed to the QTreeWidgetItem constructor.

Definition at line 164 of file qtreewidget.h.

Referenced by QTlsPrivate::X509CertificateGeneric::parseExtension().

+ Here is the caller graph for this function:

◆ write()

void QTreeWidgetItem::write ( QDataStream & out) const
virtual

Writes the item to stream out.

This only writes data from one single item.

See also
read()

Definition at line 1891 of file qtreewidget.cpp.

References QTreeWidgetItemPrivate::display, and out.

Friends And Related Symbol Documentation

◆ operator<<()

QDataStream & operator<< ( QDataStream & out,
const QTreeWidgetItem & item )
related

Writes the tree widget item item to stream out.

This operator uses QTreeWidgetItem::write().

See also
{Serializing Qt Data Types}

Definition at line 2280 of file qtreewidget.cpp.

References item, and out.

◆ operator>>()

QDataStream & operator>> ( QDataStream & in,
QTreeWidgetItem & item )
related

Reads a tree widget item from stream in into item.

This operator uses QTreeWidgetItem::read().

See also
{Serializing Qt Data Types}

Definition at line 2295 of file qtreewidget.cpp.

References item.

◆ QTreeModel

friend class QTreeModel
friend

Definition at line 24 of file qtreewidget.h.

◆ QTreeWidget

friend class QTreeWidget
friend

Definition at line 25 of file qtreewidget.h.

◆ QTreeWidgetItemIterator

friend class QTreeWidgetItemIterator
friend

Definition at line 27 of file qtreewidget.h.

◆ QTreeWidgetItemPrivate

friend class QTreeWidgetItemPrivate
friend

Definition at line 28 of file qtreewidget.h.

◆ QTreeWidgetPrivate

friend class QTreeWidgetPrivate
friend

Definition at line 26 of file qtreewidget.h.


The documentation for this class was generated from the following files: