Qt:Документация 4.3.2/qtablewidgetitem

Материал из Wiki.crossplatform.ru

Версия от 08:03, 14 ноября 2008; Root (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QTableWidgetItem Class Reference
[модуль QtGui ]

The QTableWidgetItem class provides an item for use with the QTableWidget class. More...

 #include <QTableWidgetItem>

[править] Открытые типы

[править] Открытые функции

[править] Связанные не-члены

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

[править] Подробное описание

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)));
     tableWidget->setItem(row, column, newItem);

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 setChecked() function. The corresponding checked() 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, and QTreeWidgetItem.


[править] Описание типов членов

[править]
enum QTableWidgetItem::ItemType

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 in QTableWidgetItem subclasses to ensure that custom items are treated specially.

See also type().


[править] Описание функций-членов

[править]
QTableWidgetItem::QTableWidgetItem ( int type = Type )

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

See also type().

[править]
QTableWidgetItem::QTableWidgetItem ( const QString & text, int type = Type )

Constructs a table item with the given text.

See also type().

[править]
QTableWidgetItem::QTableWidgetItem ( const QIcon & icon, const QString & text, int type = Type )

Constructs a table item with the given icon and text.

See also type().

[править]
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().

This function was introduced in Qt 4.1.

See also data() and flags().

[править]
QTableWidgetItem::~QTableWidgetItem () [virtual]

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 also setBackground() and foreground().

[править]
Qt::CheckState QTableWidgetItem::checkState () const

Returns the checked state of the table item.

See also setCheckState() and flags().

[править]
QTableWidgetItem * QTableWidgetItem::clone () const [virtual]

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

[править]
QVariant QTableWidgetItem::data ( int role ) const [virtual]

Returns the item's data for the given role.

See also setData().

[править]
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 also setFlags().

[править]
QFont QTableWidgetItem::font () const

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

See also setFont().

[править]
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 also setForeground() and background().

[править]
QIcon QTableWidgetItem::icon () const

Returns the item's icon.

See also setIcon() and iconSize.

[править]
bool QTableWidgetItem::isSelected () const

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

This function was introduced in Qt 4.2.

See also setSelected().

[править]
void QTableWidgetItem::read ( QDataStream & in ) [virtual]

Reads the item from stream in.

See also write().

[править]
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 also column().

[править]
void QTableWidgetItem::setBackground ( const QBrush & brush )

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

This function was introduced in Qt 4.2.

See also background() and setForeground().

[править]
void QTableWidgetItem::setCheckState ( Qt::CheckState state )

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

See also checkState().

[править]
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 and data().

[править]
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().

[править]
void QTableWidgetItem::setFont ( const QFont & font )

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

See also font(), setText(), and setForeground().

[править]
void QTableWidgetItem::setForeground ( const QBrush & brush )

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

This function was introduced in Qt 4.2.

See also foreground() and setBackground().

[править]
void QTableWidgetItem::setIcon ( const QIcon & icon )

Sets the item's icon to the icon specified.

See also icon(), setText(), and iconSize.

[править]
void QTableWidgetItem::setSelected ( bool select )

Sets the selected state of the item to select.

This function was introduced in Qt 4.2.

See also isSelected().

[править]
void QTableWidgetItem::setSizeHint ( const QSize & size )

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.

This function was introduced in Qt 4.1.

See also sizeHint().

[править]
void QTableWidgetItem::setStatusTip ( const QString & statusTip )

Sets the item's status tip to the string specified by statusTip.

See also statusTip(), setToolTip(), and setWhatsThis().

[править]
void QTableWidgetItem::setText ( const QString & text )

Sets the item's text to the text specified.

See also text(), setFont(), and setForeground().

[править]
void QTableWidgetItem::setTextAlignment ( int alignment )

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

See also textAlignment() and Qt::Alignment.

[править]
void QTableWidgetItem::setToolTip ( const QString & toolTip )

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

See also toolTip(), setStatusTip(), and setWhatsThis().

[править]
void QTableWidgetItem::setWhatsThis ( const QString & whatsThis )

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

See also whatsThis(), setStatusTip(), and setToolTip().

[править]
QSize QTableWidgetItem::sizeHint () const

Returns the size hint set for the table item.

This function was introduced in Qt 4.1.

See also setSizeHint().

[править]
QString QTableWidgetItem::statusTip () const

Returns the item's status tip.

See also setStatusTip().

[править]
QTableWidget * QTableWidgetItem::tableWidget () const

Returns the table widget that contains the item.

[править]
QString QTableWidgetItem::text () const

Returns the item's text.

See also setText().

[править]
int QTableWidgetItem::textAlignment () const

Returns the text alignment for the item's text.

See also setTextAlignment() and Qt::Alignment.

[править]
QString QTableWidgetItem::toolTip () const

Returns the item's tooltip.

See also setToolTip().

[править]
int QTableWidgetItem::type () const

Returns the type passed to the QTableWidgetItem constructor.

[править]
QString QTableWidgetItem::whatsThis () const

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

See also setWhatsThis().

[править]
void QTableWidgetItem::write ( QDataStream & out ) const [virtual]

Writes the item to stream out.

See also read().

[править]
bool QTableWidgetItem::operator< ( const QTableWidgetItem & other ) const [virtual]

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

[править]
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() and flags().


[править] Связанные не-члены

[править]
QDataStream & operator<< ( QDataStream & out, const QTableWidgetItem & item )

This is an overloaded member function, provided for convenience.

Writes the table widget item item to stream out.

This operator uses QTableWidgetItem::write().

See also Format of the QDataStream Operators.

[править]
QDataStream & operator>> ( QDataStream & in, QTableWidgetItem & item )

This is an overloaded member function, provided for convenience.

Reads a table widget item from stream in into item.

This operator uses QTableWidgetItem::read().

See also Format of the QDataStream Operators.


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2