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

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

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

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

Image:trolltech-logo.png

Содержание

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

The QListWidgetItem class provides an item for use with the QListWidget item view class. More...

 #include <QListWidgetItem>

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

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

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

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

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

The QListWidgetItem class provides an item for use with the QListWidget item view class.

QListWidgetItem is used to represent items in a list provided by the QListWidget class. Each item can hold several pieces of information, and will display these appropriately.

The item view convenience classes use a classic item-based interface rather than a pure model/view approach. For a more flexible list view widget, consider using the QListView class with a standard model.

List items can be automatically inserted into a list when they are constructed by specifying the list widget:

     new QListWidgetItem(tr("Hazel"), listWidget);

They can also be created without a parent widget, and later inserted into a list (see QListWidget::insertItem()).

List items are typically used to display text() and an icon(). These are set with the setText() and setIcon() functions. The appearance of the text can be customized with setFont(), setForeground(), and setBackground(). Text in list items can be aligned using the setTextAlignment() function. Tooltips, status tips and "What's This?" help can be added to list items with setToolTip(), setStatusTip(), and setWhatsThis().

By default, items are enabled, selectable, checkable, and can be the source of a drag and drop operation. Each item's flags can be changed by calling setFlags() with the appropriate value (see Qt::ItemFlags). Checkable items can be checked, unchecked and partially checked with the setCheckState() function. The corresponding checkState() function indicates what check state the item currently has.

The isHidden() function can be used to determine whether the item is hidden. Items can be hidden with setHidden().

[править] Subclassing

When subclassing QListWidgetItem 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 QListWidget, Model/View Programming, QTreeWidgetItem, and QTableWidgetItem.


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

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

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


Constant Value Description
QListWidgetItem::Type 0 The default type for list widget items.
QListWidgetItem::UserType 1000 The minimum value for custom types. Values below UserType are reserved by Qt.

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

See also type().


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

[править]
QListWidgetItem::QListWidgetItem ( QListWidget * parent = 0, int type = Type )

Constructs an empty list widget item of the specified type with the given parent. If the parent is not specified, the item will need to be inserted into a list widget with QListWidget::insertItem().

See also type().

[править]
QListWidgetItem::QListWidgetItem ( const QString & text, QListWidget * parent = 0, int type = Type )

Constructs an empty list widget item of the specified type with the given text and parent. If the parent is not specified, the item will need to be inserted into a list widget with QListWidget::insertItem().

See also type().

[править]
QListWidgetItem::QListWidgetItem ( const QIcon & icon, const QString & text, QListWidget * parent = 0, int type = Type )

Constructs an empty list widget item of the specified type with the given icon, text and parent. If the parent is not specified, the item will need to be inserted into a list widget with QListWidget::insertItem().

See also type().

[править]
QListWidgetItem::QListWidgetItem ( const QListWidgetItem & other )

Constructs a copy of other. Note that type() and listWidget() are not copied.

This function is useful when reimplementing clone().

This function was introduced in Qt 4.1.

See also data() and flags().

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

Destroys the list item.

[править]
QBrush QListWidgetItem::background () const

Returns the brush used to display the list item's background.

This function was introduced in Qt 4.2.

See also setBackground() and foreground().

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

Returns the checked state of the list item (see Qt::CheckState).

See also setCheckState() and flags().

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

Creates an exact copy of the item.

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

This function returns the item's data for a given role (see Qt::ItemDataRole). Reimplement this function if you need extra roles or special behavior for certain roles.

See also setData().

[править]
Qt::ItemFlags QListWidgetItem::flags () const

Returns the item flags for this item (see Qt::ItemFlags).

See also setFlags().

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

Returns the font used to display this list item's text.

See also setFont().

[править]
QBrush QListWidgetItem::foreground () const

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

This function was introduced in Qt 4.2.

See also setForeground() and background().

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

Returns the list item's icon.

See also setIcon() and iconSize.

[править]
bool QListWidgetItem::isHidden () const

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

This function was introduced in Qt 4.2.

See also setHidden().

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

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

This function was introduced in Qt 4.2.

See also setSelected().

[править]
QListWidget * QListWidgetItem::listWidget () const

Returns the list widget that contains the item.

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

Reads the item from stream in.

See also write().

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

Sets the background brush of the list item to the given brush.

This function was introduced in Qt 4.2.

See also background() and setForeground().

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

Sets the check state of the list item to state.

See also checkState().

[править]
void QListWidgetItem::setData ( int role, const QVariant & value ) [virtual]

This function sets the data for a given role to the given value (see Qt::ItemDataRole). Reimplement this function if you need extra roles or special behavior for certain roles.

See also Qt::ItemDataRole and data().

[править]
void QListWidgetItem::setFlags ( Qt::ItemFlags flags )

Sets the item flags for the list item to flags (see Qt::ItemFlags).

See also flags().

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

Sets the font used when painting the item to the given font.

See also font().

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

Sets the foreground brush of the list item to the given brush.

This function was introduced in Qt 4.2.

See also foreground() and setBackground().

[править]
void QListWidgetItem::setHidden ( bool hide )

Hides the item if hide is true, otherwise shows the item.

This function was introduced in Qt 4.2.

See also isHidden().

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

Sets the icon for the list item to the given icon.

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

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

Sets the selected state of the item to select.

This function was introduced in Qt 4.2.

See also isSelected().

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

Sets the size hint for the list 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 QListWidgetItem::setStatusTip ( const QString & statusTip )

Sets the status tip for the list item to the text specified by statusTip.

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

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

Sets the text for the list widget item's to the given text.

See also text().

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

Sets the list item's text alignment to alignment (see Qt::AlignmentFlag).

See also textAlignment().

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

Sets the tooltip for the list item to the text specified by toolTip.

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

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

Sets the "What's This?" help for the list item to the text specified by whatsThis.

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

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

Returns the size hint set for the list item.

This function was introduced in Qt 4.1.

See also setSizeHint().

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

Returns the list item's status tip.

See also setStatusTip().

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

Returns the list item's text.

See also setText().

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

Returns the text alignment for the list item (see Qt::AlignmentFlag).

See also setTextAlignment().

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

Returns the list item's tooltip.

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

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

Returns the type passed to the QListWidgetItem constructor.

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

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

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

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

Writes the item to stream out.

See also read().

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

Returns true if this item's text is less then other item's text; otherwise returns false.

[править]
QListWidgetItem & QListWidgetItem::operator= ( const QListWidgetItem & other )

Assigns other's data and flags to this item. Note that type() and listWidget() are not copied.

This function is useful when reimplementing clone().

See also data() and flags().


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

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

This is an overloaded member function, provided for convenience.

Writes the list widget item item to stream out.

This operator uses QListWidgetItem::write().

See also Format of the QDataStream Operators.

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

This is an overloaded member function, provided for convenience.

Reads a list widget item from stream in into item.

This operator uses QListWidgetItem::read().

See also Format of the QDataStream Operators.


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2