Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QTreeWidgetItem Class Reference

List of all members.

Detailed Description

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

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:

snippets/qtreewidget-using/mainwindow.cpp QTreeWidgetItem *cities 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 planets->setText(0

Each column in an item can have its own background color which is set with the setBackgroundColor() function. The current background color can be found with backgroundColor(). The text label for each column can be rendered with its own font and text color. These are specified with the setFont() and setTextColor() functions, and read with font() and textColor().

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 setChecked() function. The corresponding checked() function indicates whether the item is currently checked.

See also:
QTreeWidget, {Model/View Programming}, QListWidgetItem, QTableWidgetItem

Definition at line 40 of file qtreewidget.h.

Public Types

enum  { Type = 0, UserType = 1000 }

Public Member Functions

void addChild (QTreeWidgetItem *child)
void addChildren (const QList< QTreeWidgetItem * > &children)
QColor backgroundColor (int column) const
Qt::CheckState checkState (int column) const
QTreeWidgetItemchild (int index) const
int childCount () const
virtual QTreeWidgetItemclone () const
int columnCount () const
virtual QVariant data (int column, int role) const
Qt::ItemFlags flags () const
QFont font (int column) const
QIcon icon (int column) const
int indexOfChild (QTreeWidgetItem *child) const
void insertChild (int index, QTreeWidgetItem *child)
void insertChildren (int index, const QList< QTreeWidgetItem * > &children)
virtual bool operator< (const QTreeWidgetItem &other) const
QTreeWidgetItemoperator= (const QTreeWidgetItem &other)
QTreeWidgetItemparent () const
 QTreeWidgetItem (const QTreeWidgetItem &other)
 QTreeWidgetItem (QTreeWidgetItem *parent, QTreeWidgetItem *after, int type=Type)
 QTreeWidgetItem (QTreeWidgetItem *parent, const QStringList &strings, int type=Type)
 QTreeWidgetItem (QTreeWidgetItem *parent, int type=Type)
 QTreeWidgetItem (QTreeWidget *view, QTreeWidgetItem *after, int type=Type)
 QTreeWidgetItem (QTreeWidget *view, const QStringList &strings, int type=Type)
 QTreeWidgetItem (QTreeWidget *view, int type=Type)
 QTreeWidgetItem (const QStringList &strings, int type=Type)
 QTreeWidgetItem (int type=Type)
virtual void read (QDataStream &in)
void setBackgroundColor (int column, const QColor &color)
void setCheckState (int column, Qt::CheckState state)
virtual void setData (int column, int role, const QVariant &value)
void setFlags (Qt::ItemFlags flags)
void setFont (int column, const QFont &font)
void setIcon (int column, const QIcon &icon)
void setSizeHint (int column, const QSize &size)
void setStatusTip (int column, const QString &statusTip)
void setText (int column, const QString &text)
void setTextAlignment (int column, int alignment)
void setTextColor (int column, const QColor &color)
void setToolTip (int column, const QString &toolTip)
void setWhatsThis (int column, const QString &whatsThis)
QSize sizeHint (int column) const
QString statusTip (int column) const
QTreeWidgetItemtakeChild (int index)
QList< QTreeWidgetItem * > takeChildren ()
QString text (int column) const
int textAlignment (int column) const
QColor textColor (int column) const
QString toolTip (int column) const
QTreeWidgettreeWidget () const
int type () const
QString whatsThis (int column) const
virtual void write (QDataStream &out) const
virtual ~QTreeWidgetItem ()

Private Member Functions

QVariant childrenCheckState (int column) const
void sortChildren (int column, Qt::SortOrder order, bool climb)

Private Attributes

QList< QTreeWidgetItem * > children
Qt::ItemFlags itemFlags
QTreeModel * model
int rtti
QVector< QVector
< QWidgetItemData > > 


class QTreeModel
class QTreeWidget
class QTreeWidgetItemIterator

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &out, const QTreeWidgetItem &item)
QDataStreamoperator>> (QDataStream &in, QTreeWidgetItem &item)

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

Generated by  Doxygen 1.6.0   Back to index