Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QTableWidgetItem Class

TheQTableWidgetItem class provides an item for use with theQTableWidget class.More...

Header:#include <QTableWidgetItem>

Public Types

enumItemType { Type, UserType }

Public Functions

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()
QBrushbackground() const
Qt::CheckStatecheckState() const
virtual QTableWidgetItem *clone() const
intcolumn() const
virtual QVariantdata(int role) const
Qt::ItemFlagsflags() const
QFontfont() const
QBrushforeground() const
QIconicon() const
boolisSelected() const
virtual voidread(QDataStream & in)
introw() const
voidsetBackground(const QBrush & brush)
voidsetCheckState(Qt::CheckState state)
virtual voidsetData(int role, const QVariant & value)
voidsetFlags(Qt::ItemFlags flags)
voidsetFont(const QFont & font)
voidsetForeground(const QBrush & brush)
voidsetIcon(const QIcon & icon)
voidsetSelected(bool select)
voidsetSizeHint(const QSize & size)
voidsetStatusTip(const QString & statusTip)
voidsetText(const QString & text)
voidsetTextAlignment(int alignment)
voidsetToolTip(const QString & toolTip)
voidsetWhatsThis(const QString & whatsThis)
QSizesizeHint() const
QStringstatusTip() const
QTableWidget *tableWidget() const
QStringtext() const
inttextAlignment() const
QStringtoolTip() const
inttype() const
QStringwhatsThis() const
virtual voidwrite(QDataStream & out) const
virtual booloperator<(const QTableWidgetItem & other) const
QTableWidgetItem &operator=(const QTableWidgetItem & other)

Related Non-Members

QDataStream &operator<<(QDataStream & out, const QTableWidgetItem & item)
QDataStream &operator>>(QDataStream & in, QTableWidgetItem & item)

Detailed Description

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.

Subclassing

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.

Member Type Documentation

enum QTableWidgetItem::ItemType

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

ConstantValueDescription
QTableWidgetItem::Type0The default type for table widget items.
QTableWidgetItem::UserType1000The 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().

Member Function Documentation

QTableWidgetItem::QTableWidgetItem(int type = Type)

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

See alsotype().

QTableWidgetItem::QTableWidgetItem(constQString & text,int type = Type)

Constructs a table item with the giventext.

See alsotype().

QTableWidgetItem::QTableWidgetItem(constQIcon & icon, constQString & text,int type = Type)

Constructs a table item with the givenicon andtext.

See alsotype().

QTableWidgetItem::QTableWidgetItem(constQTableWidgetItem & other)

Constructs a copy ofother. Note thattype() andtableWidget() are not copied.

This function is useful when reimplementingclone().

This function was introduced in Qt 4.1.

See alsodata() andflags().

[virtual]QTableWidgetItem::~QTableWidgetItem()

Destroys the table item.

QBrush QTableWidgetItem::background() const

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

This function was introduced in Qt 4.2.

See alsosetBackground() andforeground().

Qt::CheckState QTableWidgetItem::checkState() const

Returns the checked state of the table item.

See alsosetCheckState() andflags().

[virtual]QTableWidgetItem * QTableWidgetItem::clone() const

Creates a copy of the item.

int QTableWidgetItem::column() const

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

Returns the item's data for the givenrole.

See alsosetData().

Qt::ItemFlags QTableWidgetItem::flags() const

Returns the flags used to describe the item. These determine whether the item can be checked, edited, and selected.

See alsosetFlags().

QFont QTableWidgetItem::font() const

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

See alsosetFont().

QBrush QTableWidgetItem::foreground() const

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

This function was introduced in Qt 4.2.

See alsosetForeground() andbackground().

QIcon QTableWidgetItem::icon() const

Returns the item's icon.

See alsosetIcon() andiconSize.

bool QTableWidgetItem::isSelected() const

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

int QTableWidgetItem::row() const

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

void QTableWidgetItem::setBackground(constQBrush & brush)

Sets the item's background brush to the specifiedbrush.

This function was introduced in Qt 4.2.

See alsobackground() andsetForeground().

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

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

void QTableWidgetItem::setFlags(Qt::ItemFlags flags)

Sets the flags for the item to the givenflags. These determine whether the item can be selected or modified.

See alsoflags().

void QTableWidgetItem::setFont(constQFont & font)

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

See alsofont(),setText(), andsetForeground().

void QTableWidgetItem::setForeground(constQBrush & brush)

Sets the item's foreground brush to the specifiedbrush.

This function was introduced in Qt 4.2.

See alsoforeground() andsetBackground().

void QTableWidgetItem::setIcon(constQIcon & icon)

Sets the item's icon to theicon specified.

See alsoicon(),setText(), andiconSize.

void QTableWidgetItem::setSelected(bool select)

Sets the selected state of the item toselect.

This function was introduced in Qt 4.2.

See alsoisSelected().

void QTableWidgetItem::setSizeHint(constQSize & size)

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

void QTableWidgetItem::setStatusTip(constQString & statusTip)

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

void QTableWidgetItem::setText(constQString & text)

Sets the item's text to thetext specified.

See alsotext(),setFont(), andsetForeground().

void QTableWidgetItem::setTextAlignment(int alignment)

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

See alsotextAlignment() andQt::Alignment.

void QTableWidgetItem::setToolTip(constQString & toolTip)

Sets the item's tooltip to the string specified bytoolTip.

See alsotoolTip(),setStatusTip(), andsetWhatsThis().

void QTableWidgetItem::setWhatsThis(constQString & whatsThis)

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

See alsowhatsThis(),setStatusTip(), andsetToolTip().

QSize QTableWidgetItem::sizeHint() const

Returns the size hint set for the table item.

This function was introduced in Qt 4.1.

See alsosetSizeHint().

QString QTableWidgetItem::statusTip() const

Returns the item's status tip.

See alsosetStatusTip().

QTableWidget * QTableWidgetItem::tableWidget() const

Returns the table widget that contains the item.

QString QTableWidgetItem::text() const

Returns the item's text.

See alsosetText().

int QTableWidgetItem::textAlignment() const

Returns the text alignment for the item's text.

See alsosetTextAlignment() andQt::Alignment.

QString QTableWidgetItem::toolTip() const

Returns the item's tooltip.

See alsosetToolTip().

int QTableWidgetItem::type() const

Returns the type passed to theQTableWidgetItem constructor.

QString QTableWidgetItem::whatsThis() const

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

See alsosetWhatsThis().

[virtual]void QTableWidgetItem::write(QDataStream & out) const

Writes the item to streamout.

See alsoread().

[virtual]bool QTableWidgetItem::operator<(constQTableWidgetItem & other) const

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

QTableWidgetItem & QTableWidgetItem::operator=(constQTableWidgetItem & other)

Assignsother's data and flags to this item. Note thattype() andtableWidget() are not copied.

This function is useful when reimplementingclone().

See alsodata() andflags().

Related Non-Members

QDataStream &operator<<(QDataStream & out, constQTableWidgetItem & item)

Writes the table widget itemitem to streamout.

This operator usesQTableWidgetItem::write().

See alsoSerializing Qt Data Types.

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

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.


[8]ページ先頭

©2009-2025 Movatter.jp