![]() |
Home · Overviews · Examples |
The QTableWidgetItem class provides an item for use with the QTableWidget class. More...
The QTableWidgetItem class provides an item for use with the QTableWidget class.
Table items are used to hold pieces of information for table widgets. Items usually contain text, icons, or checkboxes
The QTableWidgetItem class is a convenience class that replaces the QTableItem class in Qt 3. It provides an item for use with the QTableWidget class.
Top-level items are constructed without a parent then inserted at the position specified by a pair of row and column numbers:
QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg( pow(row, column+1))); tableWidget->setItem(row, column, newItem);
Each 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 item can be rendered with its own font and brush. These are specified with the setFont and setForeground functions, and read with font and foreground.
By default, items are enabled, editable, selectable, checkable, and can be used both as the source of a drag and drop operation and as a drop target. 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.
When subclassing QTableWidgetItem 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 QTableWidget, Model/View Programming, QListWidgetItem, and QTreeWidgetItem.
Copyright © 2007 Trolltech | Trademarks | Qt Jambi 4.3.2_01 |