Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
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 Member Functions | |
QTableWidgetItem (int type=Type) | |
Constructs a table item of the specified type that does not belong to any table. | |
QTableWidgetItem (const QString &text, int type=Type) | |
Constructs a table item with the given text. | |
QTableWidgetItem (const QIcon &icon, const QString &text, int type=Type) | |
Constructs a table item with the given icon and text. | |
QTableWidgetItem (const QTableWidgetItem &other) | |
Constructs a copy of other. | |
virtual | ~QTableWidgetItem () |
Destroys the table item. | |
virtual QTableWidgetItem * | clone () const |
Creates a copy of the item. | |
QTableWidget * | tableWidget () const |
Returns the table widget that contains the item. | |
int | row () const |
Returns the row of the item in the table. | |
int | column () const |
Returns the column of the item in the table. | |
void | setSelected (bool select) |
Sets the selected state of the item to select. | |
bool | isSelected () const |
Returns true if the item is selected, otherwise returns false . | |
Qt::ItemFlags | flags () const |
Returns the flags used to describe the item. | |
void | setFlags (Qt::ItemFlags flags) |
Sets the flags for the item to the given flags. | |
QString | text () const |
Returns the item's text. | |
void | setText (const QString &text) |
Sets the item's text to the text specified. | |
QIcon | icon () const |
Returns the item's icon. | |
void | setIcon (const QIcon &icon) |
Sets the item's icon to the icon specified. | |
QString | statusTip () const |
Returns the item's status tip. | |
void | setStatusTip (const QString &statusTip) |
Sets the status tip for the table item to the text specified by statusTip. | |
QFont | font () const |
Returns the font used to render the item's text. | |
void | setFont (const QFont &font) |
Sets the font used to display the item's text to the given font. | |
Qt::Alignment | textAlignment () const |
void | setTextAlignment (Qt::Alignment alignment) |
\obsolete [6.4] Use the overload that takes a Qt::Alignment argument. | |
QBrush | background () const |
Returns the brush used to render the item's background. | |
void | setBackground (const QBrush &brush) |
Sets the item's background brush to the specified brush. | |
QBrush | foreground () const |
Returns the brush used to render the item's foreground (e.g. | |
void | setForeground (const QBrush &brush) |
Sets the item's foreground brush to the specified brush. | |
Qt::CheckState | checkState () const |
Returns the checked state of the table item. | |
void | setCheckState (Qt::CheckState state) |
Sets the check state of the table item to be state. | |
QSize | sizeHint () const |
Returns the size hint set for the table item. | |
void | setSizeHint (const QSize &size) |
Sets the size hint for the table item to be size. | |
virtual QVariant | data (int role) const |
Returns the item's data for the given role. | |
virtual void | setData (int role, const QVariant &value) |
Sets the item's data for the given role to the specified value. | |
virtual bool | operator< (const QTableWidgetItem &other) const |
Returns true if the item is less than the other item; otherwise returns false. | |
virtual void | read (QDataStream &in) |
Reads the item from stream in. | |
virtual void | write (QDataStream &out) const |
Writes the item to stream out. | |
QTableWidgetItem & | operator= (const QTableWidgetItem &other) |
Assigns other's data and flags to this item. | |
int | type () const |
Returns the type passed to the QTableWidgetItem constructor. | |
Friends | |
class | QTableWidget |
class | QTableModel |
Related Symbols | |
(Note that these are not member symbols.) | |
QDataStream & | operator>> (QDataStream &in, QTableWidgetItem &item) |
Reads a table widget item from stream in into item. | |
QDataStream & | operator<< (QDataStream &out, const QTableWidgetItem &item) |
Writes the table widget item item to stream out. | |
The QTableWidgetItem class provides an item for use with the QTableWidget class.
\inmodule QtWidgets
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 \l{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 49 of file qtablewidget.h.
This enum describes the types that are used to describe table widget items.
\value Type The default type for table widget items. \value 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.
Enumerator | |
---|---|
Type | |
UserType |
Definition at line 54 of file qtablewidget.h.
|
explicit |
Constructs a table item of the specified type that does not belong to any table.
Definition at line 1318 of file qtablewidget.cpp.
Constructs a table item with the given text.
Definition at line 1334 of file qtablewidget.cpp.
|
explicit |
Constructs a table item with the given icon and text.
Definition at line 1351 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 1510 of file qtablewidget.cpp.
|
virtual |
Destroys the table item.
Definition at line 1367 of file qtablewidget.cpp.
|
inline |
Returns the brush used to render the item's background.
Definition at line 119 of file qtablewidget.h.
|
inline |
Returns the checked state of the table item.
Definition at line 129 of file qtablewidget.h.
|
virtual |
Creates a copy of the item.
Definition at line 1377 of file qtablewidget.cpp.
|
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 326 of file qtablewidget.h.
Referenced by testing.tools.encode_pdf_filter._Ascii85DecodePdfStream::close().
|
virtual |
Returns the item's data for the given role.
Definition at line 1418 of file qtablewidget.cpp.
|
inline |
Returns the flags used to describe the item.
These determine whether the item can be checked, edited, and selected.
Definition at line 71 of file qtablewidget.h.
|
inline |
Returns the font used to render the item's text.
Definition at line 98 of file qtablewidget.h.
|
inline |
Returns the brush used to render the item's foreground (e.g.
text).
Definition at line 124 of file qtablewidget.h.
|
inline |
Returns the item's icon.
Definition at line 78 of file qtablewidget.h.
bool QTableWidgetItem::isSelected | ( | ) | const |
Returns true
if the item is selected, otherwise returns false
.
Definition at line 1078 of file qtablewidget.cpp.
|
virtual |
Returns true
if the item is less than the other item; otherwise returns false.
Definition at line 1432 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 1525 of file qtablewidget.cpp.
|
virtual |
|
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 323 of file qtablewidget.h.
Sets the item's background brush to the specified brush.
Setting a default-constructed brush will let the view use the default color from the style.
Definition at line 121 of file qtablewidget.h.
|
inline |
Sets the check state of the table item to be state.
Definition at line 131 of file qtablewidget.h.
Sets the item's data for the given role to the specified value.
Definition at line 1390 of file qtablewidget.cpp.
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 1124 of file qtablewidget.cpp.
Sets the font used to display the item's text to the given font.
Definition at line 182 of file qtablewidget.h.
Sets the item's foreground brush to the specified brush.
Setting a default-constructed brush will let the view use the default color from the style.
Definition at line 126 of file qtablewidget.h.
Sets the item's icon to the icon specified.
Definition at line 166 of file qtablewidget.h.
void QTableWidgetItem::setSelected | ( | bool | select | ) |
Sets the selected state of the item to select.
Definition at line 1096 of file qtablewidget.cpp.
Sets the size hint for the table item to be size.
If no size hint is set or size is invalid, the item delegate will compute the size hint based on the item data.
Definition at line 136 of file qtablewidget.h.
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 169 of file qtablewidget.h.
Sets the item's text to the text specified.
Definition at line 163 of file qtablewidget.h.
|
inline |
\obsolete [6.4] Use the overload that takes a Qt::Alignment argument.
Sets the text alignment for the item's text to the alignment specified.
Sets the text alignment for the item's text to the alignment specified.
Definition at line 116 of file qtablewidget.h.
|
inline |
Returns the size hint set for the table item.
Definition at line 134 of file qtablewidget.h.
|
inline |
|
inline |
Returns the table widget that contains the item.
Definition at line 63 of file qtablewidget.h.
|
inline |
|
inline |
Returns the text alignment for the item's text.
Definition at line 106 of file qtablewidget.h.
|
inline |
Returns the type passed to the QTableWidgetItem constructor.
Definition at line 150 of file qtablewidget.h.
|
virtual |
|
related |
Writes the table widget item item to stream out.
This operator uses QTableWidgetItem::write().
Definition at line 1494 of file qtablewidget.cpp.
|
related |
Reads a table widget item from stream in into item.
This operator uses QTableWidgetItem::read().
Definition at line 1479 of file qtablewidget.cpp.
|
friend |
Definition at line 52 of file qtablewidget.h.
|
friend |
Definition at line 51 of file qtablewidget.h.