
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQTableWidgetItem class provides an item for use with theQTableWidget class.More...
| Header: | #include <QTableWidgetItem> |
| enum | ItemType { Type, UserType } |
| QTableWidgetItem(int type = Type) | |
| QTableWidgetItem(const QString & text, int type = Type) | |
| QTableWidgetItem(const QIcon & icon, const QString & text, int type = Type) | |
| QTableWidgetItem(const QTableWidgetItem & other) | |
| virtual | ~QTableWidgetItem() |
| QBrush | background() const |
| Qt::CheckState | checkState() const |
| virtual QTableWidgetItem * | clone() const |
| int | column() const |
| virtual QVariant | data(int role) const |
| Qt::ItemFlags | flags() const |
| QFont | font() const |
| QBrush | foreground() const |
| QIcon | icon() const |
| bool | isSelected() const |
| virtual void | read(QDataStream & in) |
| int | row() const |
| void | setBackground(const QBrush & brush) |
| void | setCheckState(Qt::CheckState state) |
| virtual void | setData(int role, const QVariant & value) |
| void | setFlags(Qt::ItemFlags flags) |
| void | setFont(const QFont & font) |
| void | setForeground(const QBrush & brush) |
| void | setIcon(const QIcon & icon) |
| void | setSelected(bool select) |
| void | setSizeHint(const QSize & size) |
| void | setStatusTip(const QString & statusTip) |
| void | setText(const QString & text) |
| void | setTextAlignment(int alignment) |
| void | setToolTip(const QString & toolTip) |
| void | setWhatsThis(const QString & whatsThis) |
| QSize | sizeHint() const |
| QString | statusTip() const |
| QTableWidget * | tableWidget() const |
| QString | text() const |
| int | textAlignment() const |
| QString | toolTip() const |
| int | type() const |
| QString | whatsThis() const |
| virtual void | write(QDataStream & out) const |
| virtual bool | operator<(const QTableWidgetItem & other) const |
| QTableWidgetItem & | operator=(const QTableWidgetItem & other) |
| QDataStream & | operator<<(QDataStream & out, const QTableWidgetItem & item) |
| QDataStream & | operator>>(QDataStream & in, QTableWidgetItem & item) |
TheQTableWidgetItem class provides an item for use with theQTableWidget class.
Table items are used to hold pieces of information for table widgets. Items usually contain text, icons, or checkboxes
TheQTableWidgetItem class is a convenience class that replaces theQTableItem class in Qt 3. It provides an item for use with theQTableWidget 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=newQTableWidgetItem(tr("%1").arg( pow(row, column+1))); tableWidget->setItem(row, column, newItem);
Each item can have its own background brush which is set with thesetBackground() function. The current background brush can be found withbackground(). The text label for each item can be rendered with its own font and brush. These are specified with thesetFont() andsetForeground() functions, and read withfont() andforeground().
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 callingsetFlags() with the appropriate value (seeQt::ItemFlags). Checkable items can be checked and unchecked with thesetCheckState() function. The correspondingcheckState() function indicates whether the item is currently checked.
When subclassingQTableWidgetItem 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 thanUserType.
See alsoQTableWidget,Model/View Programming,QListWidgetItem, andQTreeWidgetItem.
This enum describes the types that are used to describe table widget items.
| Constant | Value | Description |
|---|---|---|
QTableWidgetItem::Type | 0 | The default type for table widget items. |
QTableWidgetItem::UserType | 1000 | The minimum value for custom types. Values below UserType are reserved by Qt. |
You can define new user types inQTableWidgetItem subclasses to ensure that custom items are treated specially.
See alsotype().
Constructs a table item of the specifiedtype that does not belong to any table.
See alsotype().
Constructs a table item with the giventext.
See alsotype().
Constructs a table item with the givenicon andtext.
See alsotype().
Constructs a copy ofother. Note thattype() andtableWidget() are not copied.
This function is useful when reimplementingclone().
This function was introduced in Qt 4.1.
[virtual]QTableWidgetItem::~QTableWidgetItem()Destroys the table item.
Returns the brush used to render the item's background.
This function was introduced in Qt 4.2.
See alsosetBackground() andforeground().
Returns the checked state of the table item.
See alsosetCheckState() andflags().
[virtual]QTableWidgetItem * QTableWidgetItem::clone() constCreates a copy of the item.
Returns the column of the item in the table. If the item is not in a table, this function will return -1.
This function was introduced in Qt 4.2.
See alsorow().
[virtual]QVariant QTableWidgetItem::data(int role) constReturns the item's data for the givenrole.
See alsosetData().
Returns the flags used to describe the item. These determine whether the item can be checked, edited, and selected.
See alsosetFlags().
Returns the font used to render the item's text.
See alsosetFont().
Returns the brush used to render the item's foreground (e.g. text).
This function was introduced in Qt 4.2.
See alsosetForeground() andbackground().
Returns the item's icon.
See alsosetIcon() andiconSize.
Returns true if the item is selected, otherwise returns false.
This function was introduced in Qt 4.2.
See alsosetSelected().
[virtual]void QTableWidgetItem::read(QDataStream & in)Reads the item from streamin.
See alsowrite().
Returns the row of the item in the table. If the item is not in a table, this function will return -1.
This function was introduced in Qt 4.2.
See alsocolumn().
Sets the item's background brush to the specifiedbrush.
This function was introduced in Qt 4.2.
See alsobackground() andsetForeground().
Sets the check state of the table item to bestate.
See alsocheckState().
[virtual]void QTableWidgetItem::setData(int role, constQVariant & value)Sets the item's data for the givenrole to the specifiedvalue.
See alsoQt::ItemDataRole anddata().
Sets the flags for the item to the givenflags. These determine whether the item can be selected or modified.
See alsoflags().
Sets the font used to display the item's text to the givenfont.
See alsofont(),setText(), andsetForeground().
Sets the item's foreground brush to the specifiedbrush.
This function was introduced in Qt 4.2.
See alsoforeground() andsetBackground().
Sets the item's icon to theicon specified.
See alsoicon(),setText(), andiconSize.
Sets the selected state of the item toselect.
This function was introduced in Qt 4.2.
See alsoisSelected().
Sets the size hint for the table item to besize. If no size hint is set, the item delegate will compute the size hint based on the item data.
This function was introduced in Qt 4.1.
See alsosizeHint().
Sets the status tip for the table item to the text specified bystatusTip.QTableWidget mouse tracking needs to be enabled for this feature to work.
See alsostatusTip(),setToolTip(), andsetWhatsThis().
Sets the item's text to thetext specified.
See alsotext(),setFont(), andsetForeground().
Sets the text alignment for the item's text to thealignment specified.
See alsotextAlignment() andQt::Alignment.
Sets the item's tooltip to the string specified bytoolTip.
See alsotoolTip(),setStatusTip(), andsetWhatsThis().
Sets the item's "What's This?" help to the string specified bywhatsThis.
See alsowhatsThis(),setStatusTip(), andsetToolTip().
Returns the size hint set for the table item.
This function was introduced in Qt 4.1.
See alsosetSizeHint().
Returns the item's status tip.
See alsosetStatusTip().
Returns the table widget that contains the item.
Returns the item's text.
See alsosetText().
Returns the text alignment for the item's text.
See alsosetTextAlignment() andQt::Alignment.
Returns the item's tooltip.
See alsosetToolTip().
Returns the type passed to theQTableWidgetItem constructor.
Returns the item's "What's This?" help.
See alsosetWhatsThis().
[virtual]void QTableWidgetItem::write(QDataStream & out) constWrites the item to streamout.
See alsoread().
[virtual]bool QTableWidgetItem::operator<(constQTableWidgetItem & other) constReturns true if the item is less than theother item; otherwise returns false.
Assignsother's data and flags to this item. Note thattype() andtableWidget() are not copied.
This function is useful when reimplementingclone().
Writes the table widget itemitem to streamout.
This operator usesQTableWidgetItem::write().
See alsoSerializing Qt Data Types.
Reads a table widget item from streamin intoitem.
This operator usesQTableWidgetItem::read().
See alsoSerializing Qt Data Types.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.