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

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:

doc/src/snippets/qtreewidget-using/mainwindow.cpp 3

Items can be added in a particular order by specifying the item they follow when they are constructed:

doc/src/snippets/qtreewidget-using/mainwindow.cpp 5

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.

Definition at line 65 of file qtreewidget.h.


Public Types

enum  ChildIndicatorPolicy { ShowIndicator, DontShowIndicator, DontShowIndicatorWhenChildless }
enum  ItemType { Type = 0, UserType = 1000 }

Public Member Functions

void addChild (QTreeWidgetItem *child)
void addChildren (const QList< QTreeWidgetItem * > &children)
QBrush background (int column) const
QColor backgroundColor (int column) const
Qt::CheckState checkState (int column) const
QTreeWidgetItemchild (int index) const
int childCount () const
QTreeWidgetItem::ChildIndicatorPolicy childIndicatorPolicy () const
virtual QTreeWidgetItemclone () const
int columnCount () const
virtual QVariant data (int column, int role) const
Qt::ItemFlags flags () const
QFont font (int column) const
QBrush foreground (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)
bool isDisabled () const
bool isExpanded () const
bool isFirstColumnSpanned () const
bool isHidden () const
bool isSelected () const
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 removeChild (QTreeWidgetItem *child)
void setBackground (int column, const QBrush &brush)
void setBackgroundColor (int column, const QColor &color)
void setCheckState (int column, Qt::CheckState state)
void setChildIndicatorPolicy (QTreeWidgetItem::ChildIndicatorPolicy policy)
virtual void setData (int column, int role, const QVariant &value)
void setDisabled (bool disabled)
void setExpanded (bool expand)
void setFirstColumnSpanned (bool span)
void setFlags (Qt::ItemFlags flags)
void setFont (int column, const QFont &font)
void setForeground (int column, const QBrush &brush)
void setHidden (bool hide)
void setIcon (int column, const QIcon &icon)
void setSelected (bool select)
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
void sortChildren (int column, Qt::SortOrder order)
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 executePendingSort () const
void itemChanged ()
void sortChildren (int column, Qt::SortOrder order, bool climb)

Private Attributes

QList< QTreeWidgetItem * > children
QTreeWidgetItemPrivate * d
Qt::ItemFlags itemFlags
QTreeWidgetItempar
int rtti
QVector< QVector
< QWidgetItemData > > 
values
QTreeWidgetview

Friends

class QTreeModel
class QTreeWidget
class QTreeWidgetItemIterator
class QTreeWidgetItemPrivate
class QTreeWidgetPrivate

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