Qt 4.8
|
The QTableWidgetItem class provides an item for use with the QTableWidget class. More...
#include <qtablewidget.h>
Public Types | |
enum | ItemType { Type = 0, UserType = 1000 } |
This enum describes the types that are used to describe table widget items. More... | |
Public Functions | |
QBrush | background () const |
Returns the brush used to render the item's background. More... | |
QColor | backgroundColor () const |
This function is deprecated. More... | |
Qt::CheckState | checkState () const |
Returns the checked state of the table item. More... | |
virtual QTableWidgetItem * | clone () const |
Creates a copy of the item. More... | |
int | column () const |
Returns the column of the item in the table. More... | |
virtual QVariant | data (int role) const |
Returns the item's data for the given role. More... | |
Qt::ItemFlags | flags () const |
Returns the flags used to describe the item. More... | |
QFont | font () const |
Returns the font used to render the item's text. More... | |
QBrush | foreground () const |
Returns the brush used to render the item's foreground (e. More... | |
QIcon | icon () const |
Returns the item's icon. More... | |
bool | isSelected () const |
Returns true if the item is selected, otherwise returns false. More... | |
virtual bool | operator< (const QTableWidgetItem &other) const |
Returns true if the item is less than the other item; otherwise returns false. More... | |
QTableWidgetItem & | operator= (const QTableWidgetItem &other) |
Assigns other's data and flags to this item. More... | |
QTableWidgetItem (int type=Type) | |
Constructs a table item of the specified type that does not belong to any table. More... | |
QTableWidgetItem (const QString &text, int type=Type) | |
Constructs a table item with the given text. More... | |
QTableWidgetItem (const QIcon &icon, const QString &text, int type=Type) | |
Constructs a table item with the given icon and text. More... | |
QTableWidgetItem (const QTableWidgetItem &other) | |
Constructs a copy of other. More... | |
virtual void | read (QDataStream &in) |
Reads the item from stream in. More... | |
int | row () const |
Returns the row of the item in the table. More... | |
void | setBackground (const QBrush &brush) |
Sets the item's background brush to the specified brush. More... | |
void | setBackgroundColor (const QColor &color) |
This function is deprecated. More... | |
void | setCheckState (Qt::CheckState state) |
Sets the check state of the table item to be state. More... | |
virtual void | setData (int role, const QVariant &value) |
Sets the item's data for the given role to the specified value. More... | |
void | setFlags (Qt::ItemFlags flags) |
Sets the flags for the item to the given flags. More... | |
void | setFont (const QFont &font) |
Sets the font used to display the item's text to the given font. More... | |
void | setForeground (const QBrush &brush) |
Sets the item's foreground brush to the specified brush. More... | |
void | setIcon (const QIcon &icon) |
Sets the item's icon to the icon specified. More... | |
void | setSelected (bool select) |
Sets the selected state of the item to select. More... | |
void | setSizeHint (const QSize &size) |
Sets the size hint for the table item to be size. More... | |
void | setStatusTip (const QString &statusTip) |
Sets the status tip for the table item to the text specified by statusTip. More... | |
void | setText (const QString &text) |
Sets the item's text to the text specified. More... | |
void | setTextAlignment (int alignment) |
Sets the text alignment for the item's text to the alignment specified. More... | |
void | setTextColor (const QColor &color) |
This function is deprecated. More... | |
void | setToolTip (const QString &toolTip) |
Sets the item's tooltip to the string specified by toolTip. More... | |
void | setWhatsThis (const QString &whatsThis) |
Sets the item's "What's This?" help to the string specified by whatsThis. More... | |
QSize | sizeHint () const |
Returns the size hint set for the table item. More... | |
QString | statusTip () const |
Returns the item's status tip. More... | |
QTableWidget * | tableWidget () const |
Returns the table widget that contains the item. More... | |
QString | text () const |
Returns the item's text. More... | |
int | textAlignment () const |
Returns the text alignment for the item's text. More... | |
QColor | textColor () const |
This function is deprecated. More... | |
QString | toolTip () const |
Returns the item's tooltip. More... | |
int | type () const |
Returns the type passed to the QTableWidgetItem constructor. More... | |
QString | whatsThis () const |
Returns the item's "What's This?" help. More... | |
virtual void | write (QDataStream &out) const |
Writes the item to stream out. More... | |
virtual | ~QTableWidgetItem () |
Destroys the table item. More... | |
Properties | |
QTableWidgetItemPrivate * | d |
Qt::ItemFlags | itemFlags |
int | rtti |
QVector< QWidgetItemData > | values |
QTableWidget * | view |
Friends | |
class | QTableModel |
class | QTableWidget |
Related Functions | |
(Note that these are not member functions.) | |
QDataStream & | operator<< (QDataStream &out, const QTableWidgetItem &item) |
Writes the table widget item item to stream out. More... | |
QDataStream & | operator>> (QDataStream &in, QTableWidgetItem &item) |
Reads a table widget item from stream in into item. 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:
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 setCheckState() function. The corresponding checkState() 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 .
Definition at line 82 of file qtablewidget.h.
This enum describes the types that are used to describe table widget items.
You can define new user types in QTableWidgetItem subclasses to ensure that custom items are treated specially.
Enumerator | |
---|---|
Type | |
UserType |
Definition at line 87 of file qtablewidget.h.
QTableWidgetItem::QTableWidgetItem | ( | int | type = Type | ) |
Constructs a table item of the specified type that does not belong to any table.
Definition at line 1410 of file qtablewidget.cpp.
Referenced by clone().
Constructs a table item with the given text.
Definition at line 1426 of file qtablewidget.cpp.
|
explicit |
Constructs a table item with the given icon and text.
Definition at line 1443 of file qtablewidget.cpp.
QTableWidgetItem::QTableWidgetItem | ( | const QTableWidgetItem & | other | ) |
Constructs a copy of other.
Note that type() and tableWidget() are not copied.
This function is useful when reimplementing clone().
Definition at line 1595 of file qtablewidget.cpp.
|
virtual |
Destroys the table item.
Definition at line 1459 of file qtablewidget.cpp.
|
inline |
Returns the brush used to render the item's background.
Definition at line 145 of file qtablewidget.h.
|
inline |
This function is deprecated.
Use background() instead.
Definition at line 140 of file qtablewidget.h.
|
inline |
Returns the checked state of the table item.
Definition at line 160 of file qtablewidget.h.
|
virtual |
Creates a copy of the item.
Definition at line 1470 of file qtablewidget.cpp.
Referenced by QTableModel::createItem().
|
inline |
Returns the column of the item in the table.
If the item is not in a table, this function will return -1.
Definition at line 362 of file qtablewidget.h.
Referenced by QTableWidgetPrivate::_q_dataChanged(), and QTableWidgetPrivate::_q_sort().
|
virtual |
Returns the item's data for the given role.
Definition at line 1503 of file qtablewidget.cpp.
Referenced by QTableModel::data(), QTableModel::headerData(), and operator<().
|
inline |
Returns the flags used to describe the item.
These determine whether the item can be checked, edited, and selected.
Definition at line 104 of file qtablewidget.h.
Referenced by QTableModel::itemChanged().
|
inline |
Returns the font used to render the item's text.
Definition at line 131 of file qtablewidget.h.
|
inline |
Returns the brush used to render the item's foreground (e.
g. text).
\sa background()
Definition at line 155 of file qtablewidget.h.
|
inline |
Returns the item's icon.
Definition at line 111 of file qtablewidget.h.
|
inline |
Returns true if the item is selected, otherwise returns false.
Definition at line 368 of file qtablewidget.h.
|
virtual |
Returns true if the item is less than the other item; otherwise returns false.
Definition at line 1516 of file qtablewidget.cpp.
QTableWidgetItem & QTableWidgetItem::operator= | ( | const QTableWidgetItem & | other | ) |
Assigns other's data and flags to this item.
Note that type() and tableWidget() are not copied.
This function is useful when reimplementing clone().
Definition at line 1610 of file qtablewidget.cpp.
|
virtual |
Reads the item from stream in.
Definition at line 1529 of file qtablewidget.cpp.
Referenced by operator>>().
|
inline |
Returns the row of the item in the table.
If the item is not in a table, this function will return -1.
Definition at line 359 of file qtablewidget.h.
|
inline |
Sets the item's background brush to the specified brush.
Definition at line 147 of file qtablewidget.h.
|
inline |
This function is deprecated.
Use setBackground() instead.
Definition at line 142 of file qtablewidget.h.
|
inline |
Sets the check state of the table item to be state.
Definition at line 162 of file qtablewidget.h.
|
virtual |
Sets the item's data for the given role to the specified value.
Definition at line 1480 of file qtablewidget.cpp.
Referenced by QTableWidgetItem(), QTableModel::setData(), and QTableModel::setHeaderData().
void QTableWidgetItem::setFlags | ( | Qt::ItemFlags | flags | ) |
Sets the flags for the item to the given flags.
These determine whether the item can be selected or modified.
Definition at line 1151 of file qtablewidget.cpp.
|
inline |
Sets the font used to display the item's text to the given font.
Definition at line 210 of file qtablewidget.h.
|
inline |
Sets the item's foreground brush to the specified brush.
Definition at line 157 of file qtablewidget.h.
|
inline |
Sets the item's icon to the icon specified.
Definition at line 194 of file qtablewidget.h.
|
inline |
Sets the selected state of the item to select.
Definition at line 365 of file qtablewidget.h.
|
inline |
Sets the size hint for the table item to be size.
If no size hint is set, the item delegate will compute the size hint based on the item data.
Definition at line 167 of file qtablewidget.h.
|
inline |
Sets the status tip for the table item to the text specified by statusTip.
QTableWidget mouse tracking needs to be enabled for this feature to work.
Definition at line 197 of file qtablewidget.h.
|
inline |
Sets the item's text to the text specified.
Definition at line 191 of file qtablewidget.h.
Referenced by QTableWidget::setHorizontalHeaderLabels(), and QTableWidget::setVerticalHeaderLabels().
|
inline |
Sets the text alignment for the item's text to the alignment specified.
Definition at line 137 of file qtablewidget.h.
|
inline |
This function is deprecated.
Use setForeground() instead.
Definition at line 152 of file qtablewidget.h.
|
inline |
Sets the item's tooltip to the string specified by toolTip.
Definition at line 201 of file qtablewidget.h.
|
inline |
Sets the item's "What's This?" help to the string specified by whatsThis.
Definition at line 206 of file qtablewidget.h.
|
inline |
Returns the size hint set for the table item.
Definition at line 165 of file qtablewidget.h.
|
inline |
Returns the item's status tip.
Definition at line 115 of file qtablewidget.h.
|
inline |
|
inline |
Returns the item's text.
Definition at line 107 of file qtablewidget.h.
|
inline |
Returns the text alignment for the item's text.
Definition at line 135 of file qtablewidget.h.
|
inline |
This function is deprecated.
Use foreground() instead.
Definition at line 150 of file qtablewidget.h.
|
inline |
Returns the item's tooltip.
Definition at line 120 of file qtablewidget.h.
|
inline |
Returns the type passed to the QTableWidgetItem constructor.
Definition at line 181 of file qtablewidget.h.
|
inline |
Returns the item's "What's This?" help.
Definition at line 126 of file qtablewidget.h.
|
virtual |
Writes the item to stream out.
Definition at line 1539 of file qtablewidget.cpp.
Referenced by operator<<().
|
related |
Writes the table widget item item to stream out.
This operator uses QTableWidgetItem::write().
Definition at line 1574 of file qtablewidget.cpp.
|
related |
Reads a table widget item from stream in into item.
This operator uses QTableWidgetItem::read().
Definition at line 1556 of file qtablewidget.cpp.
|
friend |
Definition at line 85 of file qtablewidget.h.
|
friend |
Definition at line 84 of file qtablewidget.h.
|
private |
Definition at line 187 of file qtablewidget.h.
Referenced by QTableModel::index(), QTableModel::setItem(), QTableModel::takeItem(), and ~QTableWidgetItem().
|
private |
Definition at line 188 of file qtablewidget.h.
Referenced by operator=(), QTableModel::setHorizontalHeaderItem(), QTableModel::setVerticalHeaderItem(), QTableModel::takeHorizontalHeaderItem(), and QTableModel::takeVerticalHeaderItem().
|
private |
Definition at line 184 of file qtablewidget.h.
|
private |
Definition at line 185 of file qtablewidget.h.
Referenced by data(), QTableModel::itemData(), operator=(), read(), setData(), and write().
|
private |
Definition at line 186 of file qtablewidget.h.
Referenced by QTableModel::clear(), QTableModel::clearContents(), QTableModel::removeColumns(), QTableModel::removeRows(), setData(), QTableModel::setHorizontalHeaderItem(), QTableWidget::setHorizontalHeaderItem(), QTableModel::setItem(), QTableWidget::setItem(), QTableModel::setVerticalHeaderItem(), QTableWidget::setVerticalHeaderItem(), QTableModel::takeHorizontalHeaderItem(), QTableWidget::takeHorizontalHeaderItem(), QTableModel::takeItem(), QTableWidget::takeItem(), QTableModel::takeVerticalHeaderItem(), QTableWidget::takeVerticalHeaderItem(), and ~QTableWidgetItem().