Qt 4.8
Public Types | Public Functions | Properties | Friends | Related Functions | List of all members
QTableWidgetItem Class Reference

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 QTableWidgetItemclone () 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...
 
QTableWidgetItemoperator= (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...
 
QTableWidgettableWidget () 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

QTableWidgetItemPrivated
 
Qt::ItemFlags itemFlags
 
int rtti
 
QVector< QWidgetItemDatavalues
 
QTableWidgetview
 

Friends

class QTableModel
 
class QTableWidget
 

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &out, const QTableWidgetItem &item)
 Writes the table widget item item to stream out. More...
 
QDataStreamoperator>> (QDataStream &in, QTableWidgetItem &item)
 Reads a table widget item from stream in into item. More...
 

Detailed Description

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)));

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.

Subclassing

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, QTreeWidgetItem

Definition at line 82 of file qtablewidget.h.

Enumerations

◆ ItemType

This enum describes the types that are used to describe table widget items.

  • Type The default type for table widget items.
  • UserType The minimum value for custom types. Values below UserType are reserved by Qt.

You can define new user types in QTableWidgetItem subclasses to ensure that custom items are treated specially.

See also
type()
Enumerator
Type 
UserType 

Definition at line 87 of file qtablewidget.h.

Constructors and Destructors

◆ QTableWidgetItem() [1/4]

QTableWidgetItem::QTableWidgetItem ( int  type = Type)

Constructs a table item of the specified type that does not belong to any table.

See also
type()

Definition at line 1410 of file qtablewidget.cpp.

Referenced by clone().

◆ QTableWidgetItem() [2/4]

QTableWidgetItem::QTableWidgetItem ( const QString text,
int  type = Type 
)
explicit

Constructs a table item with the given text.

See also
type()

Definition at line 1426 of file qtablewidget.cpp.

1427  : rtti(type), view(0), d(new QTableWidgetItemPrivate(this)),
1434 {
1435  setData(Qt::DisplayRole, text);
1436 }
QTableWidget * view
Definition: qtablewidget.h:186
QTableWidgetItemPrivate * d
Definition: qtablewidget.h:187
int type() const
Returns the type passed to the QTableWidgetItem constructor.
Definition: qtablewidget.h:181
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.
Qt::ItemFlags itemFlags
Definition: qtablewidget.h:188

◆ QTableWidgetItem() [3/4]

QTableWidgetItem::QTableWidgetItem ( const QIcon icon,
const QString text,
int  type = Type 
)
explicit

Constructs a table item with the given icon and text.

See also
type()

Definition at line 1443 of file qtablewidget.cpp.

1444  : rtti(type), view(0), d(new QTableWidgetItemPrivate(this)),
1451 {
1452  setData(Qt::DecorationRole, icon);
1453  setData(Qt::DisplayRole, text);
1454 }
QTableWidget * view
Definition: qtablewidget.h:186
QTableWidgetItemPrivate * d
Definition: qtablewidget.h:187
int type() const
Returns the type passed to the QTableWidgetItem constructor.
Definition: qtablewidget.h:181
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.
Qt::ItemFlags itemFlags
Definition: qtablewidget.h:188

◆ QTableWidgetItem() [4/4]

QTableWidgetItem::QTableWidgetItem ( const QTableWidgetItem other)

Constructs a copy of other.

Since
4.1

Note that type() and tableWidget() are not copied.

This function is useful when reimplementing clone().

See also
data(), flags()

Definition at line 1595 of file qtablewidget.cpp.

1596  : rtti(Type), values(other.values), view(0),
1597  d(new QTableWidgetItemPrivate(this)),
1598  itemFlags(other.itemFlags)
1599 {
1600 }
QTableWidget * view
Definition: qtablewidget.h:186
QVector< QWidgetItemData > values
Definition: qtablewidget.h:185
QTableWidgetItemPrivate * d
Definition: qtablewidget.h:187
Qt::ItemFlags itemFlags
Definition: qtablewidget.h:188

◆ ~QTableWidgetItem()

QTableWidgetItem::~QTableWidgetItem ( )
virtual

Destroys the table item.

Definition at line 1459 of file qtablewidget.cpp.

1460 {
1461  if (QTableModel *model = (view ? qobject_cast<QTableModel*>(view->model()) : 0))
1462  model->removeItem(this);
1463  view = 0;
1464  delete d;
1465 }
QTableWidget * view
Definition: qtablewidget.h:186
QTableWidgetItemPrivate * d
Definition: qtablewidget.h:187
QAbstractItemModel * model() const
Returns the model that this view is presenting.

Functions

◆ background()

QBrush QTableWidgetItem::background ( ) const
inline

Returns the brush used to render the item's background.

Since
4.2
See also
foreground()

Definition at line 145 of file qtablewidget.h.

virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ backgroundColor()

QColor QTableWidgetItem::backgroundColor ( ) const
inline

This function is deprecated.

Use background() instead.

Definition at line 140 of file qtablewidget.h.

The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ checkState()

Qt::CheckState QTableWidgetItem::checkState ( ) const
inline

Returns the checked state of the table item.

See also
flags()

Definition at line 160 of file qtablewidget.h.

161  { return static_cast<Qt::CheckState>(data(Qt::CheckStateRole).toInt()); }
CheckState
Definition: qnamespace.h:1607
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.

◆ clone()

QTableWidgetItem * QTableWidgetItem::clone ( ) const
virtual

Creates a copy of the item.

Definition at line 1470 of file qtablewidget.cpp.

Referenced by QTableModel::createItem().

1471 {
1472  return new QTableWidgetItem(*this);
1473 }
QTableWidgetItem(int type=Type)
Constructs a table item of the specified type that does not belong to any table.

◆ column()

int QTableWidgetItem::column ( ) const
inline

Returns the column of the item in the table.

Since
4.2

If the item is not in a table, this function will return -1.

See also
row()

Definition at line 362 of file qtablewidget.h.

Referenced by QTableWidgetPrivate::_q_dataChanged(), and QTableWidgetPrivate::_q_sort().

363 { return (view ? view->column(this) : -1); }
QTableWidget * view
Definition: qtablewidget.h:186
int column(const QTableWidgetItem *item) const
Returns the column for the item.

◆ data()

QVariant QTableWidgetItem::data ( int  role) const
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<().

1504 {
1505  role = (role == Qt::EditRole ? Qt::DisplayRole : role);
1506  for (int i = 0; i < values.count(); ++i)
1507  if (values.at(i).role == role)
1508  return values.at(i).value;
1509  return QVariant();
1510 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QVector< QWidgetItemData > values
Definition: qtablewidget.h:185
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350

◆ flags()

Qt::ItemFlags QTableWidgetItem::flags ( ) const
inline

Returns the flags used to describe the item.

These determine whether the item can be checked, edited, and selected.

See also
setFlags()

Definition at line 104 of file qtablewidget.h.

Referenced by QTableModel::itemChanged().

104 { return itemFlags; }
Qt::ItemFlags itemFlags
Definition: qtablewidget.h:188

◆ font()

QFont QTableWidgetItem::font ( ) const
inline

Returns the font used to render the item's text.

See also
setFont()

Definition at line 131 of file qtablewidget.h.

132  { return qvariant_cast<QFont>(data(Qt::FontRole)); }
virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ foreground()

QBrush QTableWidgetItem::foreground ( ) const
inline

Returns the brush used to render the item's foreground (e.

Since
4.2

g. text).

\sa background()

Definition at line 155 of file qtablewidget.h.

virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ icon()

QIcon QTableWidgetItem::icon ( ) const
inline

Returns the item's icon.

See also
setIcon(), {QAbstractItemView::iconSize}{iconSize}

Definition at line 111 of file qtablewidget.h.

virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60

◆ isSelected()

bool QTableWidgetItem::isSelected ( ) const
inline

Returns true if the item is selected, otherwise returns false.

Since
4.2
See also
setSelected()

Definition at line 368 of file qtablewidget.h.

369 { return (view ? view->isItemSelected(this) : false); }
bool isItemSelected(const QTableWidgetItem *item) const
Returns true if the item is selected, otherwise returns false.
QTableWidget * view
Definition: qtablewidget.h:186

◆ operator<()

bool QTableWidgetItem::operator< ( const QTableWidgetItem other) const
virtual

Returns true if the item is less than the other item; otherwise returns false.

Definition at line 1516 of file qtablewidget.cpp.

1517 {
1518  const QVariant v1 = data(Qt::DisplayRole), v2 = other.data(Qt::DisplayRole);
1520 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static bool variantLessThan(const QVariant &v1, const QVariant &v2)
This function is used by our Q{Tree,Widget,Table}WidgetModel classes to sort.
virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.

◆ operator=()

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().

See also
data(), flags()

Definition at line 1610 of file qtablewidget.cpp.

1611 {
1612  values = other.values;
1613  itemFlags = other.itemFlags;
1614  return *this;
1615 }
QVector< QWidgetItemData > values
Definition: qtablewidget.h:185
Qt::ItemFlags itemFlags
Definition: qtablewidget.h:188

◆ read()

void QTableWidgetItem::read ( QDataStream in)
virtual

Reads the item from stream in.

See also
write()

Definition at line 1529 of file qtablewidget.cpp.

Referenced by operator>>().

1530 {
1531  in >> values;
1532 }
QVector< QWidgetItemData > values
Definition: qtablewidget.h:185

◆ row()

int QTableWidgetItem::row ( ) const
inline

Returns the row of the item in the table.

Since
4.2

If the item is not in a table, this function will return -1.

See also
column()

Definition at line 359 of file qtablewidget.h.

360 { return (view ? view->row(this) : -1); }
QTableWidget * view
Definition: qtablewidget.h:186
int row(const QTableWidgetItem *item) const
Returns the row for the item.

◆ setBackground()

void QTableWidgetItem::setBackground ( const QBrush brush)
inline

Sets the item's background brush to the specified brush.

Since
4.2
See also
setForeground()

Definition at line 147 of file qtablewidget.h.

148  { setData(Qt::BackgroundRole, brush); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ setBackgroundColor()

void QTableWidgetItem::setBackgroundColor ( const QColor color)
inline

This function is deprecated.

Use setBackground() instead.

Definition at line 142 of file qtablewidget.h.

143  { setData(Qt::BackgroundColorRole, color); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ setCheckState()

void QTableWidgetItem::setCheckState ( Qt::CheckState  state)
inline

Sets the check state of the table item to be state.

Definition at line 162 of file qtablewidget.h.

163  { setData(Qt::CheckStateRole, state); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ setData()

void QTableWidgetItem::setData ( int  role,
const QVariant value 
)
virtual

Sets the item's data for the given role to the specified value.

See also
Qt::ItemDataRole, data()

Definition at line 1480 of file qtablewidget.cpp.

Referenced by QTableWidgetItem(), QTableModel::setData(), and QTableModel::setHeaderData().

1481 {
1482  bool found = false;
1483  role = (role == Qt::EditRole ? Qt::DisplayRole : role);
1484  for (int i = 0; i < values.count(); ++i) {
1485  if (values.at(i).role == role) {
1486  if (values[i].value == value)
1487  return;
1488 
1489  values[i].value = value;
1490  found = true;
1491  break;
1492  }
1493  }
1494  if (!found)
1495  values.append(QWidgetItemData(role, value));
1496  if (QTableModel *model = (view ? qobject_cast<QTableModel*>(view->model()) : 0))
1497  model->itemChanged(this);
1498 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QTableWidget * view
Definition: qtablewidget.h:186
QVector< QWidgetItemData > values
Definition: qtablewidget.h:185
T value(int i) const
Returns the value at index position i in the vector.
Definition: qvector.h:559
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QAbstractItemModel * model() const
Returns the model that this view is presenting.

◆ setFlags()

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.

See also
flags()

Definition at line 1151 of file qtablewidget.cpp.

1152 {
1153  itemFlags = aflags;
1154  if (QTableModel *model = (view ? qobject_cast<QTableModel*>(view->model()) : 0))
1155  model->itemChanged(this);
1156 }
QTableWidget * view
Definition: qtablewidget.h:186
QAbstractItemModel * model() const
Returns the model that this view is presenting.
Qt::ItemFlags itemFlags
Definition: qtablewidget.h:188

◆ setFont()

void QTableWidgetItem::setFont ( const QFont font)
inline

Sets the font used to display the item's text to the given font.

See also
font() setText() setForeground()

Definition at line 210 of file qtablewidget.h.

211 { setData(Qt::FontRole, afont); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ setForeground()

void QTableWidgetItem::setForeground ( const QBrush brush)
inline

Sets the item's foreground brush to the specified brush.

Since
4.2
See also
setBackground()

Definition at line 157 of file qtablewidget.h.

158  { setData(Qt::ForegroundRole, brush); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ setIcon()

void QTableWidgetItem::setIcon ( const QIcon icon)
inline

Sets the item's icon to the icon specified.

See also
icon(), setText(), {QAbstractItemView::iconSize}{iconSize}

Definition at line 194 of file qtablewidget.h.

195 { setData(Qt::DecorationRole, aicon); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ setSelected()

void QTableWidgetItem::setSelected ( bool  select)
inline

Sets the selected state of the item to select.

Since
4.2
See also
isSelected()

Definition at line 365 of file qtablewidget.h.

366 { if (view) view->setItemSelected(this, aselect); }
QTableWidget * view
Definition: qtablewidget.h:186
void setItemSelected(const QTableWidgetItem *item, bool select)
Selects or deselects item depending on select.

◆ setSizeHint()

void QTableWidgetItem::setSizeHint ( const QSize size)
inline

Sets the size hint for the table item to be size.

Since
4.1

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.

168  { setData(Qt::SizeHintRole, size); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ setStatusTip()

void QTableWidgetItem::setStatusTip ( const QString statusTip)
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.

See also
statusTip() setToolTip() setWhatsThis()

Definition at line 197 of file qtablewidget.h.

198 { setData(Qt::StatusTipRole, astatusTip); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ setText()

void QTableWidgetItem::setText ( const QString text)
inline

Sets the item's text to the text specified.

See also
text() setFont() setForeground()

Definition at line 191 of file qtablewidget.h.

Referenced by QTableWidget::setHorizontalHeaderLabels(), and QTableWidget::setVerticalHeaderLabels().

192 { setData(Qt::DisplayRole, atext); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ setTextAlignment()

void QTableWidgetItem::setTextAlignment ( int  alignment)
inline

Sets the text alignment for the item's text to the alignment specified.

See also
Qt::Alignment

Definition at line 137 of file qtablewidget.h.

138  { setData(Qt::TextAlignmentRole, alignment); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ setTextColor()

void QTableWidgetItem::setTextColor ( const QColor color)
inline

This function is deprecated.

Use setForeground() instead.

Definition at line 152 of file qtablewidget.h.

153  { setData(Qt::TextColorRole, color); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ setToolTip()

void QTableWidgetItem::setToolTip ( const QString toolTip)
inline

Sets the item's tooltip to the string specified by toolTip.

See also
toolTip() setStatusTip() setWhatsThis()

Definition at line 201 of file qtablewidget.h.

202 { setData(Qt::ToolTipRole, atoolTip); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ setWhatsThis()

void QTableWidgetItem::setWhatsThis ( const QString whatsThis)
inline

Sets the item's "What's This?" help to the string specified by whatsThis.

See also
whatsThis() setStatusTip() setToolTip()

Definition at line 206 of file qtablewidget.h.

207 { setData(Qt::WhatsThisRole, awhatsThis); }
virtual void setData(int role, const QVariant &value)
Sets the item&#39;s data for the given role to the specified value.

◆ sizeHint()

QSize QTableWidgetItem::sizeHint ( ) const
inline

Returns the size hint set for the table item.

Since
4.1

Definition at line 165 of file qtablewidget.h.

virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ statusTip()

QString QTableWidgetItem::statusTip ( ) const
inline

Returns the item's status tip.

See also
setStatusTip()

Definition at line 115 of file qtablewidget.h.

116  { return data(Qt::StatusTipRole).toString(); }
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.

◆ tableWidget()

QTableWidget * QTableWidgetItem::tableWidget ( ) const
inline

Returns the table widget that contains the item.

Definition at line 96 of file qtablewidget.h.

96 { return view; }
QTableWidget * view
Definition: qtablewidget.h:186

◆ text()

QString QTableWidgetItem::text ( ) const
inline

Returns the item's text.

See also
setText()

Definition at line 107 of file qtablewidget.h.

108  { return data(Qt::DisplayRole).toString(); }
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.

◆ textAlignment()

int QTableWidgetItem::textAlignment ( ) const
inline

Returns the text alignment for the item's text.

See also
Qt::Alignment

Definition at line 135 of file qtablewidget.h.

136  { return data(Qt::TextAlignmentRole).toInt(); }
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.

◆ textColor()

QColor QTableWidgetItem::textColor ( ) const
inline

This function is deprecated.

Use foreground() instead.

Definition at line 150 of file qtablewidget.h.

The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ toolTip()

QString QTableWidgetItem::toolTip ( ) const
inline

Returns the item's tooltip.

See also
setToolTip()

Definition at line 120 of file qtablewidget.h.

121  { return data(Qt::ToolTipRole).toString(); }
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.

◆ type()

int QTableWidgetItem::type ( ) const
inline

Returns the type passed to the QTableWidgetItem constructor.

Definition at line 181 of file qtablewidget.h.

181 { return rtti; }

◆ whatsThis()

QString QTableWidgetItem::whatsThis ( ) const
inline

Returns the item's "What's This?" help.

See also
setWhatsThis()

Definition at line 126 of file qtablewidget.h.

127  { return data(Qt::WhatsThisRole).toString(); }
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
virtual QVariant data(int role) const
Returns the item&#39;s data for the given role.

◆ write()

void QTableWidgetItem::write ( QDataStream out) const
virtual

Writes the item to stream out.

See also
read()

Definition at line 1539 of file qtablewidget.cpp.

Referenced by operator<<().

1540 {
1541  out << values;
1542 }
QVector< QWidgetItemData > values
Definition: qtablewidget.h:185

Friends and Related Functions

◆ operator<<()

QDataStream & operator<< ( QDataStream out,
const QTableWidgetItem item 
)
related

Writes the table widget item item to stream out.

This operator uses QTableWidgetItem::write().

See also
{Serializing Qt Data Types}

Definition at line 1574 of file qtablewidget.cpp.

1575 {
1576  item.write(out);
1577  return out;
1578 }
virtual void write(QDataStream &out) const
Writes the item to stream out.

◆ operator>>()

QDataStream & operator>> ( QDataStream in,
QTableWidgetItem item 
)
related

Reads a table widget item from stream in into item.

This operator uses QTableWidgetItem::read().

See also
{Serializing Qt Data Types}

Definition at line 1556 of file qtablewidget.cpp.

1557 {
1558  item.read(in);
1559  return in;
1560 }
virtual void read(QDataStream &in)
Reads the item from stream in.

◆ QTableModel

friend class QTableModel
friend

Definition at line 85 of file qtablewidget.h.

◆ QTableWidget

friend class QTableWidget
friend

Definition at line 84 of file qtablewidget.h.

Properties

◆ d

QTableWidgetItemPrivate* QTableWidgetItem::d
private

◆ itemFlags

Qt::ItemFlags QTableWidgetItem::itemFlags
private

◆ rtti

int QTableWidgetItem::rtti
private

Definition at line 184 of file qtablewidget.h.

◆ values

QVector<QWidgetItemData> QTableWidgetItem::values
private

Definition at line 185 of file qtablewidget.h.

Referenced by data(), QTableModel::itemData(), operator=(), read(), setData(), and write().

◆ view

QTableWidget* QTableWidgetItem::view
private

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