QTreeWidgetItem Class Reference |
enum | ChildIndicatorPolicy { ShowIndicator, DontShowIndicator, DontShowIndicatorWhenChildless } |
enum | ItemType { Type, UserType } |
QTreeWidgetItem ( int type = Type ) | |
QTreeWidgetItem ( const QStringList & strings, int type = Type ) | |
QTreeWidgetItem ( QTreeWidget * parent, int type = Type ) | |
QTreeWidgetItem ( QTreeWidget * parent, const QStringList & strings, int type = Type ) | |
QTreeWidgetItem ( QTreeWidget * parent, QTreeWidgetItem * preceding, int type = Type ) | |
QTreeWidgetItem ( QTreeWidgetItem * parent, int type = Type ) | |
QTreeWidgetItem ( QTreeWidgetItem * parent, const QStringList & strings, int type = Type ) | |
QTreeWidgetItem ( QTreeWidgetItem * parent, QTreeWidgetItem * preceding, int type = Type ) | |
QTreeWidgetItem ( const QTreeWidgetItem & other ) | |
virtual | ~QTreeWidgetItem () |
void | addChild ( QTreeWidgetItem * child ) |
void | addChildren ( const QList<QTreeWidgetItem *> & children ) |
QBrush | background ( int column ) const |
Qt::CheckState | checkState ( int column ) const |
QTreeWidgetItem * | child ( int index ) const |
int | childCount () const |
QTreeWidgetItem::ChildIndicatorPolicy | childIndicatorPolicy () const |
virtual QTreeWidgetItem * | clone () 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 |
QTreeWidgetItem * | parent () const |
virtual void | read ( QDataStream & in ) |
void | removeChild ( QTreeWidgetItem * child ) |
void | setBackground ( int column, const QBrush & brush ) |
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 | 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 |
QTreeWidgetItem * | takeChild ( int index ) |
QList<QTreeWidgetItem *> | takeChildren () |
QString | text ( int column ) const |
int | textAlignment ( int column ) const |
QString | toolTip ( int column ) const |
QTreeWidget * | treeWidget () const |
int | type () const |
QString | whatsThis ( int column ) const |
virtual void | write ( QDataStream & out ) const |
virtual bool | operator< ( const QTreeWidgetItem & other ) const |
QTreeWidgetItem & | operator= ( const QTreeWidgetItem & other ) |
void | emitDataChanged () |
QDataStream & | operator<< ( QDataStream & out, const QTreeWidgetItem & item ) |
QDataStream & | operator>> ( QDataStream & in, QTreeWidgetItem & item ) |
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.
See also QTreeWidget, QTreeWidgetItemIterator, Model/View Programming, QListWidgetItem, and QTableWidgetItem.
Constant | Value | Description |
---|---|---|
QTreeWidgetItem::ShowIndicator | 0 | The controls for expanding and collapsing will be shown for this item even if there are no children. |
QTreeWidgetItem::DontShowIndicator | 1 | 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. |
QTreeWidgetItem::DontShowIndicatorWhenChildless | 2 | The controls for expanding and collapsing will be shown if the item contains children. |
This enum was introduced in Qt 4.3.
This enum describes the types that are used to describe tree widget items.
Constant | Value | Description |
---|---|---|
QTreeWidgetItem::Type | 0 | The default type for tree widget items. |
QTreeWidgetItem::UserType | 1000 | 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().
Constructs a tree widget item of the specified type. The item must be inserted into a tree widget.
See also 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.
See also type().
Constructs a tree widget item of the specified type and appends it to the items in the given parent.
See also 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().
Constructs a tree widget item of the specified type and inserts it into the given parent after the preceding item.
See also type().
Constructs a tree widget item and append it to the given parent.
See also 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().
Constructs a tree widget item of the specified type that is inserted into the parent after the preceding child item.
See also type().
Constructs a copy of other. Note that type() and treeWidget() are not copied.
This function is useful when reimplementing clone().
This function was introduced in Qt 4.1.
Destroys this tree widget item.
Appends the child item to the list of children.
See also insertChild() and takeChild().
Appends the given list of children to the item.
This function was introduced in Qt 4.1.
See also insertChildren() and takeChildren().
Returns the brush used to render the background of the specified column.
This function was introduced in Qt 4.2.
See also setBackground() and foreground().
Returns the check state of the label in the given column.
See also setCheckState() and Qt::CheckState.
Returns the item at the given index in the list of the item's children.
See also parent().
Returns the number of child items.
Returns the item indicator policy. This policy decides when the tree branch expand/collapse indicator is shown.
See also setChildIndicatorPolicy().
Creates a deep copy of the item and of its children.
Returns the number of columns in the item.
Returns the value for the item's column and role.
See also setData().
Causes the model associated with this item to emit a dataChanged() signal for this item.
You normally only need to call this function if you have subclassed QTreeWidgetItem and reimplemented data() and/or setData().
This function was introduced in Qt 4.5.
See also setData().
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.
See also setFlags().
Returns the font used to render the text in the specified column.
See also setFont().
Returns the brush used to render the foreground (e.g. text) of the specified column.
This function was introduced in Qt 4.2.
See also setForeground() and background().
Returns the icon that is displayed in the specified column.
See also setIcon() and iconSize.
Returns the index of the given child in the item's list of children.
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.
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.
This function was introduced in Qt 4.1.
Returns true if the item is disabled; otherwise returns false.
This function was introduced in Qt 4.3.
See also setFlags().
Returns true if the item is expanded, otherwise returns false.
This function was introduced in Qt 4.2.
See also setExpanded().
Returns true if the item is spanning all the columns in a row; otherwise returns false.
This function was introduced in Qt 4.3.
See also setFirstColumnSpanned().
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.6-snapshot | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com