Qt Jambi Home

com.trolltech.qt.gui
Class QListWidgetItem

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.gui.QListWidgetItem
All Implemented Interfaces:
QtJambiInterface

public class QListWidgetItem
extends QtJambiObject

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, QTableWidgetItem

Nested Class Summary
static class QListWidgetItem.ItemType
          This enum describes the types that are used to describe list widget items.
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Constructor Summary
QListWidgetItem()
          Equivalent to QListWidgetItem(0, Type).
QListWidgetItem(QIcon icon, java.lang.String text)
          Equivalent to QListWidgetItem(icon, text, 0, Type).
QListWidgetItem(QIcon icon, java.lang.String text, QListWidget view)
          Equivalent to QListWidgetItem(icon, text, view, Type).
QListWidgetItem(QIcon icon, java.lang.String text, QListWidget view, int type)
          Constructs an empty list widget item of the specified type with the given icon, text and view.
QListWidgetItem(QListWidget view)
          Equivalent to QListWidgetItem(view, Type).
QListWidgetItem(QListWidget view, int type)
          Constructs an empty list widget item of the specified type with the given view.
QListWidgetItem(QListWidgetItem other)
          Constructs a copy of other.
QListWidgetItem(java.lang.String text)
          Equivalent to QListWidgetItem(text, 0, Type).
QListWidgetItem(java.lang.String text, QListWidget view)
          Equivalent to QListWidgetItem(text, view, Type).
QListWidgetItem(java.lang.String text, QListWidget view, int type)
          Constructs an empty list widget item of the specified type with the given text and view.
 
Method Summary
 QBrush background()
          Returns the brush used to display the list item's background.
 Qt.CheckState checkState()
          Returns the checked state of the list item (see Qt::CheckState).
 QListWidgetItem clone()
          Creates an exact copy of the item.
 java.lang.Object data(int role)
          This function returns the item's data for a given role (see Qt::ItemDataRole).
 Qt.ItemFlags flags()
          Returns the item flags for this item (see Qt::ItemFlags).
 QFont font()
          Returns the font used to display this list item's text.
 QBrush foreground()
          Returns the brush used to display the list item's foreground (e.g. text).
static QListWidgetItem fromNativePointer(QNativePointer nativePointer)
          This function returns the QListWidgetItem instance pointed to by nativePointer
 QIcon icon()
          Returns the list item's icon.
 boolean isHidden()
          Returns true if the item is hidden, otherwise returns false.
 boolean isSelected()
          Returns true if the item is selected, otherwise returns false.
 QListWidget listWidget()
          Returns the list widget that contains the item.
 void read(QDataStream in)
          Reads the item from stream in.
 void readFrom(QDataStream in)
          Reads a QListWidgetItem from in.
 void setBackground(QBrush brush)
          Sets the background brush of the list item to the given brush.
 void setCheckState(Qt.CheckState state)
          Sets the check state of the list item to state.
 void setData(int role, java.lang.Object value)
          This function sets the data for a given role to the given value (see Qt::ItemDataRole).
 void setFlags(Qt.ItemFlag... flags)
          Sets the item flags for the list item to flags (see Qt::ItemFlags).
 void setFlags(Qt.ItemFlags flags)
          Sets the item flags for the list item to flags (see Qt::ItemFlags).
 void setFont(QFont font)
          Sets the font used when painting the item to the given font.
 void setForeground(QBrush brush)
          Sets the foreground brush of the list item to the given brush.
 void setHidden(boolean hide)
          Hides the item if hide is true, otherwise shows the item.
 void setIcon(QIcon icon)
          Sets the icon for the list item to the given icon.
 void setSelected(boolean select)
          Sets the selected state of the item to select.
 void setSizeHint(QSize size)
          Sets the size hint for the list item to be size.
 void setStatusTip(java.lang.String statusTip)
          Sets the status tip for the list item to the text specified by statusTip.
 void setText(java.lang.String text)
          Sets the text for the list widget item's to the given text.
 void setTextAlignment(int alignment)
          Sets the list item's text alignment to alignment (see Qt::AlignmentFlag).
 void setToolTip(java.lang.String toolTip)
          Sets the tooltip for the list item to the text specified by toolTip.
 void setWhatsThis(java.lang.String whatsThis)
          Sets the "What's This?" help for the list item to the text specified by whatsThis.
 QSize sizeHint()
          Returns the size hint set for the list item.
 java.lang.String statusTip()
          Returns the list item's status tip.
 java.lang.String text()
          Returns the list item's text.
 int textAlignment()
          Returns the text alignment for the list item (see Qt::AlignmentFlag).
 java.lang.String toolTip()
          Returns the list item's tooltip.
 int type()
          Returns the type passed to the QListWidgetItem constructor.
 java.lang.String whatsThis()
          Returns the list item's "What's This?" help text.
 void write(QDataStream out)
          Writes the item to stream out.
 void writeTo(QDataStream out)
          Writes thisQListWidgetItem to out.
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QListWidgetItem

public QListWidgetItem(QIcon icon,
                       java.lang.String text,
                       QListWidget view)

Equivalent to QListWidgetItem(icon, text, view, Type).


QListWidgetItem

public QListWidgetItem(QIcon icon,
                       java.lang.String text)

Equivalent to QListWidgetItem(icon, text, 0, Type).


QListWidgetItem

public QListWidgetItem(QIcon icon,
                       java.lang.String text,
                       QListWidget view,
                       int type)

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

See Also:
type

QListWidgetItem

public QListWidgetItem(QListWidget view)

Equivalent to QListWidgetItem(view, Type).


QListWidgetItem

public QListWidgetItem()

Equivalent to QListWidgetItem(0, Type).


QListWidgetItem

public QListWidgetItem(QListWidget view,
                       int type)

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

See Also:
type

QListWidgetItem

public QListWidgetItem(QListWidgetItem other)

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

This function is useful when reimplementing clone.

See Also:
data, flags

QListWidgetItem

public QListWidgetItem(java.lang.String text,
                       QListWidget view)

Equivalent to QListWidgetItem(text, view, Type).


QListWidgetItem

public QListWidgetItem(java.lang.String text)

Equivalent to QListWidgetItem(text, 0, Type).


QListWidgetItem

public QListWidgetItem(java.lang.String text,
                       QListWidget view,
                       int type)

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

See Also:
type
Method Detail

background

public final QBrush background()

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

See Also:
setBackground, foreground

checkState

public final Qt.CheckState checkState()

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

See Also:
setCheckState, flags

flags

public final Qt.ItemFlags flags()

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

See Also:
setFlags

font

public final QFont font()

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

See Also:
setFont

foreground

public final QBrush foreground()

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

See Also:
setForeground, background

icon

public final QIcon icon()

Returns the list item's icon.

See Also:
setIcon, iconSize

isHidden

public final boolean isHidden()

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

See Also:
setHidden

isSelected

public final boolean isSelected()

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

See Also:
setSelected

listWidget

public final QListWidget listWidget()

Returns the list widget that contains the item.


writeTo

public final void writeTo(QDataStream out)
Writes thisQListWidgetItem to out.


readFrom

public final void readFrom(QDataStream in)
Reads a QListWidgetItem from in.


setBackground

public final void setBackground(QBrush brush)

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

See Also:
background, setForeground

setCheckState

public final void setCheckState(Qt.CheckState state)

Sets the check state of the list item to state.

See Also:
checkState

setFlags

public final void setFlags(Qt.ItemFlag... flags)

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

See Also:
flags

setFlags

public final void setFlags(Qt.ItemFlags flags)

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

See Also:
flags

setFont

public final void setFont(QFont font)

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

See Also:
font

setForeground

public final void setForeground(QBrush brush)

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

See Also:
foreground, setBackground

setHidden

public final void setHidden(boolean hide)

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

See Also:
isHidden

setIcon

public final void setIcon(QIcon icon)

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

See Also:
icon, text, iconSize

setSelected

public final void setSelected(boolean select)

Sets the selected state of the item to select.

See Also:
isSelected

setSizeHint

public final void setSizeHint(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.

See Also:
sizeHint

setStatusTip

public final void setStatusTip(java.lang.String statusTip)

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

See Also:
statusTip, setToolTip, setWhatsThis

setText

public final void setText(java.lang.String text)

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

See Also:
text

setTextAlignment

public final void setTextAlignment(int alignment)

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

See Also:
textAlignment

setToolTip

public final void setToolTip(java.lang.String toolTip)

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

See Also:
toolTip, setStatusTip, setWhatsThis

setWhatsThis

public final void setWhatsThis(java.lang.String whatsThis)

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

See Also:
whatsThis, setStatusTip, setToolTip

sizeHint

public final QSize sizeHint()

Returns the size hint set for the list item.

See Also:
setSizeHint

statusTip

public final java.lang.String statusTip()

Returns the list item's status tip.

See Also:
setStatusTip

text

public final java.lang.String text()

Returns the list item's text.

See Also:
setText

textAlignment

public final int textAlignment()

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

See Also:
setTextAlignment

toolTip

public final java.lang.String toolTip()

Returns the list item's tooltip.

See Also:
setToolTip, statusTip, whatsThis

type

public final int type()

Returns the type passed to the QListWidgetItem constructor.


whatsThis

public final java.lang.String whatsThis()

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

See Also:
setWhatsThis, statusTip, toolTip

clone

public QListWidgetItem clone()

Creates an exact copy of the item.

Overrides:
clone in class java.lang.Object

data

public java.lang.Object data(int role)

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

read

public void read(QDataStream in)

Reads the item from stream in.

See Also:
write

setData

public void setData(int role,
                    java.lang.Object value)

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, data

write

public void write(QDataStream out)

Writes the item to stream out.

See Also:
read

fromNativePointer

public static QListWidgetItem fromNativePointer(QNativePointer nativePointer)
This function returns the QListWidgetItem instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

Qt Jambi Home