Qt Jambi Home

com.trolltech.qt.gui
Class QListWidget

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QWidget
                  extended by com.trolltech.qt.gui.QFrame
                      extended by com.trolltech.qt.gui.QAbstractScrollArea
                          extended by com.trolltech.qt.gui.QAbstractItemView
                              extended by com.trolltech.qt.gui.QListView
                                  extended by com.trolltech.qt.gui.QListWidget
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QListWidget
extends QListView

The QListWidget class provides an item-based list widget.

QListWidget is a convenience class that provides a list view similar to the one supplied by QListView, but with a classic item-based interface for adding and removing items. QListWidget uses an internal model to manage each QListWidgetItem in the list.

For a more flexible list view widget, use the QListView class with a standard model.

List widgets are constructed in the same way as other widgets:

        QListWidget *listWidget = new QListWidget(this);

The selectionMode of a list widget determines how many of the items in the list can be selected at the same time, and whether complex selections of items can be created. This can be set with the setSelectionMode function.

There are two ways to add items to the list: they can be constructed with the list widget as their parent widget, or they can be constructed with no parent widget and added to the list later. If a list widget already exists when the items are constructed, the first method is easier to use:

        new QListWidgetItem(tr("Oak"), listWidget);
        new QListWidgetItem(tr("Fir"), listWidget);
        new QListWidgetItem(tr("Pine"), listWidget);

If you need to insert a new item into the list at a particular position, it is more required to construct the item without a parent widget and use the insertItem function to place it within the list. The list widget will take ownership of the item.

        QListWidgetItem *newItem = new QListWidgetItem;
        newItem->setText(itemText);
        listWidget->insertItem(row, newItem);

For multiple items, insertItems can be used instead. The number of items in the list is found with the count function. To remove items from the list, use takeItem.

The current item in the list can be found with currentItem, and changed with setCurrentItem. The user can also change the current item by navigating with the keyboard or clicking on a different item. When the current item changes, the currentItemChanged signal is emitted with the new current item and the item that was previously current.

Screenshot of a Windows XP style list widgetScreenshot of a Macintosh style table widgetScreenshot of a Plastique style table widget
A Windows XP style list widget.A Macintosh style list widget.A Plastique style list widget.

See Also:
QListWidgetItem, QListView, QTreeView, Model/View Programming, Config Dialog Example

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QListView
QListView.Flow, QListView.LayoutMode, QListView.Movement, QListView.ResizeMode, QListView.ViewMode
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QAbstractItemView
QAbstractItemView.CursorAction, QAbstractItemView.DragDropMode, QAbstractItemView.DropIndicatorPosition, QAbstractItemView.EditTrigger, QAbstractItemView.EditTriggers, QAbstractItemView.ScrollHint, QAbstractItemView.ScrollMode, QAbstractItemView.SelectionBehavior, QAbstractItemView.SelectionMode, QAbstractItemView.State
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QFrame
QFrame.Shadow, QFrame.Shape, QFrame.StyleMask
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
QWidget.RenderFlag, QWidget.RenderFlags
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, 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>
 
Field Summary
 QSignalEmitter.Signal2<QListWidgetItem,QListWidgetItem> currentItemChanged
          This signal is emitted whenever the current item changes.
 QSignalEmitter.Signal1<java.lang.Integer> currentRowChanged
          This signal is emitted whenever the current item changes.
 QSignalEmitter.Signal1<java.lang.String> currentTextChanged
          This signal is emitted whenever the current item changes.
 QSignalEmitter.Signal1<QListWidgetItem> itemActivated
          This signal is emitted when the item is activated.
 QSignalEmitter.Signal1<QListWidgetItem> itemChanged
          This signal is emitted whenever the data of item has changed.
 QSignalEmitter.Signal1<QListWidgetItem> itemClicked
          This signal is emitted with the specified item when a mouse button is clicked on an item in the widget.
 QSignalEmitter.Signal1<QListWidgetItem> itemDoubleClicked
          This signal is emitted with the specified item when a mouse button is double clicked on an item in the widget.
 QSignalEmitter.Signal1<QListWidgetItem> itemEntered
          This signal is emitted when the mouse cursor enters an item.
 QSignalEmitter.Signal1<QListWidgetItem> itemPressed
          This signal is emitted with the specified item when a mouse button is pressed on an item in the widget.
 QSignalEmitter.Signal0 itemSelectionChanged
          This signal is emitted whenever the selection changes.
 
Fields inherited from class com.trolltech.qt.gui.QListView
indexesMoved
 
Fields inherited from class com.trolltech.qt.gui.QAbstractItemView
activated, clicked, doubleClicked, entered, pressed, viewportEntered
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Constructor Summary
QListWidget()
          Equivalent to QListWidget(0).
QListWidget(QWidget parent)
          Constructs an empty QListWidget with the given parent.
 
Method Summary
 void addItem(QListWidgetItem item)
          Inserts the item at the the end of the list widget.
 void addItem(java.lang.String label)
          Inserts an item with the text label at the end of the list widget.
 void addItems(java.util.List<java.lang.String> labels)
          Inserts items with the text labels at the end of the list widget.
 void clear()
          Removes all items and selections in the view.
 void closePersistentEditor(QListWidgetItem item)
          Closes the persistent editor for the given item.
 int count()
          Returns the number of items in the list including any hidden items..
 QListWidgetItem currentItem()
          Returns the current item.
 int currentRow()
          Returns the row of the current item..
protected  void dropEvent(QDropEvent event)
          This function is reimplemented for internal reasons.
protected  boolean dropMimeData(int index, QMimeData data, Qt.DropAction action)
          Handles the data supplied by a drag and drop operation that ended with the given action in the given index.
 void editItem(QListWidgetItem item)
          Starts editing the item if it is editable.
 boolean event(QEvent e)
          This function is reimplemented for internal reasons.
 java.util.List<QListWidgetItem> findItems(java.lang.String text, Qt.MatchFlag... flags)
          Finds items with the text that matches the string text using the given flags.
 java.util.List<QListWidgetItem> findItems(java.lang.String text, Qt.MatchFlags flags)
          Finds items with the text that matches the string text using the given flags.
static QListWidget fromNativePointer(QNativePointer nativePointer)
          This function returns the QListWidget instance pointed to by nativePointer
protected  QModelIndex indexFromItem(QListWidgetItem item)
          Returns the QModelIndex assocated with the given item.
 void insertItem(int row, QListWidgetItem item)
          Inserts the item at the position in the list given by row.
 void insertItem(int row, java.lang.String label)
          Inserts an item with the text label in the list widget at the position given by row.
 void insertItems(int row, java.util.List<java.lang.String> labels)
          Inserts items from the list of labels into the list, starting at the given row.
 boolean isSortingEnabled()
          Returns whether sorting is enabled.
 QListWidgetItem item(int row)
          Returns the item that occupies the given row in the list if one has been set; otherwise returns 0.
 QListWidgetItem itemAt(int x, int y)
          Returns a pointer to the item at the coordinates (x, y).
 QListWidgetItem itemAt(QPoint p)
          Returns a pointer to the item at the coordinates p.
protected  QListWidgetItem itemFromIndex(QModelIndex index)
          Returns a pointer to the QListWidgetItem assocated with the given index.
protected  java.util.List<QListWidgetItem> items(QMimeData data)
          Returns a list of pointers to the items contained in the data object.
 QWidget itemWidget(QListWidgetItem item)
          Returns the widget displayed in the given item.
protected  QMimeData mimeData(java.util.List<QListWidgetItem> items)
          Returns an object that contains a serialized description of the specified items.
protected  java.util.List<java.lang.String> mimeTypes()
          Returns a list of MIME types that can be used to describe a list of listwidget items.
 void openPersistentEditor(QListWidgetItem item)
          Opens an editor for the given item.
 void removeItemWidget(QListWidgetItem item)
          Removes the widget set on the given item.
 int row(QListWidgetItem item)
          Returns the row containing the given item.
 void scrollToItem(QListWidgetItem item)
          Equivalent to scrollToItem(item, EnsureVisible).
 void scrollToItem(QListWidgetItem item, QAbstractItemView.ScrollHint hint)
          Scrolls the view if necessary to ensure that the item is visible.
 java.util.List<QListWidgetItem> selectedItems()
          Returns a list of all selected items in the list widget.
 void setCurrentItem(QListWidgetItem item)
          Sets the current item to item.
 void setCurrentRow(int row)
          Sets the row of the current item.
 void setItemWidget(QListWidgetItem item, QWidget widget)
          Sets the widget to be displayed in the give item.
 void setModel(QAbstractItemModel model)
          Deprecated. 
 void setSortingEnabled(boolean enable)
          Sets whether sorting is enabled to enable.
 void sortItems()
          Equivalent to sortItems(Qt::AscendingOrder).
 void sortItems(Qt.SortOrder order)
          Sorts all the items in the list widget according to the specified order.
protected  Qt.DropActions supportedDropActions()
          Returns the drop actions supported by this view.
 QListWidgetItem takeItem(int row)
          Removes and returns the item from the given row in the list widget; otherwise returns 0.
 QRect visualItemRect(QListWidgetItem item)
          Returns the rectangle on the viewport occupied by the item at item.
 
Methods inherited from class com.trolltech.qt.gui.QListView
batchSize, clearPropertyFlags, contentsSize, currentChanged, dataChanged, doItemsLayout, dragLeaveEvent, dragMoveEvent, flow, gridSize, horizontalOffset, indexAt, internalDrag, internalDrag, internalDrop, isIndexHidden, isRowHidden, isSelectionRectVisible, isWrapping, layoutMode, modelColumn, mouseMoveEvent, mouseReleaseEvent, moveCursor, movement, paintEvent, rectForIndex, reset, resizeContents, resizeEvent, resizeMode, rowsAboutToBeRemoved, rowsInserted, scrollContentsBy, scrollTo, selectedIndexes, selectionChanged, setBatchSize, setFlow, setGridSize, setLayoutMode, setModelColumn, setMovement, setPositionForIndex, setResizeMode, setRootIndex, setRowHidden, setSelection, setSelectionRectVisible, setSpacing, setUniformItemSizes, setViewMode, setWordWrap, setWrapping, spacing, startDrag, timerEvent, uniformItemSizes, updateGeometries, verticalOffset, viewMode, viewOptions, visualRect, visualRegionForSelection, wordWrap
 
Methods inherited from class com.trolltech.qt.gui.QAbstractItemView
alternatingRowColors, clearSelection, closeEditor, closePersistentEditor, commitData, currentIndex, dirtyRegionOffset, doAutoScroll, dragDropMode, dragDropOverwriteMode, dragEnabled, dragEnterEvent, dropIndicatorPosition, edit, edit, editorDestroyed, editTriggers, executeDelayedItemsLayout, focusInEvent, focusNextPrevChild, focusOutEvent, hasAutoScroll, horizontalScrollbarAction, horizontalScrollbarValueChanged, horizontalScrollMode, iconSize, indexWidget, inputMethodEvent, inputMethodQuery, itemDelegate, itemDelegate, itemDelegateForColumn, itemDelegateForRow, keyboardSearch, keyPressEvent, model, mouseDoubleClickEvent, mousePressEvent, openPersistentEditor, rootIndex, scheduleDelayedItemsLayout, scrollDirtyRegion, scrollTo, scrollToBottom, scrollToTop, selectAll, selectionBehavior, selectionCommand, selectionCommand, selectionMode, selectionModel, setAlternatingRowColors, setAutoScroll, setCurrentIndex, setDirtyRegion, setDragDropMode, setDragDropOverwriteMode, setDragEnabled, setDropIndicatorShown, setEditTriggers, setEditTriggers, setHorizontalScrollMode, setIconSize, setIndexWidget, setItemDelegate, setItemDelegateForColumn, setItemDelegateForRow, setSelectionBehavior, setSelectionMode, setSelectionModel, setState, setTabKeyNavigation, setTextElideMode, setVerticalScrollMode, showDropIndicator, sizeHintForColumn, sizeHintForIndex, sizeHintForRow, startAutoScroll, startDrag, state, stopAutoScroll, tabKeyNavigation, textElideMode, update, updateEditorData, updateEditorGeometries, verticalScrollbarAction, verticalScrollbarValueChanged, verticalScrollMode, viewportEvent
 
Methods inherited from class com.trolltech.qt.gui.QAbstractScrollArea
addScrollBarWidget, addScrollBarWidget, contextMenuEvent, cornerWidget, horizontalScrollBar, horizontalScrollBarPolicy, maximumViewportSize, minimumSizeHint, paintEngine, scrollBarWidgets, scrollBarWidgets, setCornerWidget, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setupViewport, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportMargins, sizeHint, verticalScrollBar, verticalScrollBarPolicy, viewport, wheelEvent
 
Methods inherited from class com.trolltech.qt.gui.QFrame
changeEvent, drawFrame, frameRect, frameShadow, frameShape, frameStyle, frameWidth, lineWidth, midLineWidth, setFrameRect, setFrameShadow, setFrameShape, setFrameStyle, setLineWidth, setMidLineWidth
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuPolicy, createWinId, cursor, depth, destroy, destroy, destroy, devType, ensurePolished, enterEvent, focusNextChild, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyReleaseEvent, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumWidth, mouseGrabber, move, move, moveEvent, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, overrideWindowState, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, width, widthMM, window, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

currentItemChanged

public final QSignalEmitter.Signal2<QListWidgetItem,QListWidgetItem> currentItemChanged

This signal is emitted whenever the current item changes. The previous item is the item that previously had the focus, current is the new current item.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QListWidgetItem current, com.trolltech.qt.gui.QListWidgetItem previous)
void mySlot(com.trolltech.qt.gui.QListWidgetItem current)
void mySlot()


currentRowChanged

public final QSignalEmitter.Signal1<java.lang.Integer> currentRowChanged

This signal is emitted whenever the current item changes. The currentRow is the row of the current item. If there is no current item, the currentRow is -1.

Compatible Slot Signatures:
void mySlot(int currentRow)
void mySlot()


currentTextChanged

public final QSignalEmitter.Signal1<java.lang.String> currentTextChanged

This signal is emitted whenever the current item changes. The currentText is the text data in the current item. If there is no current item, the currentText is invalid.

Compatible Slot Signatures:
void mySlot(java.lang.String currentText)
void mySlot()


itemActivated

public final QSignalEmitter.Signal1<QListWidgetItem> itemActivated

This signal is emitted when the item is activated. The item is activated when the user clicks or double clicks on it, depending on the system configuration. It is also activated when the user presses the activation key (on Windows and X11 this is the Return key, on Mac OS X it is Ctrl+0).

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QListWidgetItem item)
void mySlot()


itemChanged

public final QSignalEmitter.Signal1<QListWidgetItem> itemChanged

This signal is emitted whenever the data of item has changed.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QListWidgetItem item)
void mySlot()


itemClicked

public final QSignalEmitter.Signal1<QListWidgetItem> itemClicked

This signal is emitted with the specified item when a mouse button is clicked on an item in the widget.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QListWidgetItem item)
void mySlot()
See Also:
itemPressed, itemDoubleClicked


itemDoubleClicked

public final QSignalEmitter.Signal1<QListWidgetItem> itemDoubleClicked

This signal is emitted with the specified item when a mouse button is double clicked on an item in the widget.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QListWidgetItem item)
void mySlot()
See Also:
itemClicked, itemPressed


itemEntered

public final QSignalEmitter.Signal1<QListWidgetItem> itemEntered

This signal is emitted when the mouse cursor enters an item. The item is the item entered. This signal is only emitted when mouseTracking is turned on, or when a mouse button is pressed while moving into an item.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QListWidgetItem item)
void mySlot()


itemPressed

public final QSignalEmitter.Signal1<QListWidgetItem> itemPressed

This signal is emitted with the specified item when a mouse button is pressed on an item in the widget.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QListWidgetItem item)
void mySlot()
See Also:
itemClicked, itemDoubleClicked


itemSelectionChanged

public final QSignalEmitter.Signal0 itemSelectionChanged

This signal is emitted whenever the selection changes.

Compatible Slot Signature:
void mySlot()
See Also:
selectedItems, isItemSelected, currentItemChanged

Constructor Detail

QListWidget

public QListWidget()

Equivalent to QListWidget(0).


QListWidget

public QListWidget(QWidget parent)

Constructs an empty QListWidget with the given parent.

Method Detail

addItem

public final void addItem(QListWidgetItem item)

Inserts the item at the the end of the list widget.

Warning: A QListWidgetItem can only be added to a QListWidget once. Adding the same QListWidgetItem multiple times to a QListWidget will result in undefined behavior.

See Also:
insertItem

addItem

public final void addItem(java.lang.String label)

Inserts an item with the text label at the end of the list widget.


addItems

public final void addItems(java.util.List<java.lang.String> labels)

Inserts items with the text labels at the end of the list widget.

See Also:
insertItems

clear

public final void clear()

Removes all items and selections in the view.


closePersistentEditor

public final void closePersistentEditor(QListWidgetItem item)

Closes the persistent editor for the given item.

See Also:
openPersistentEditor

count

public final int count()

Returns the number of items in the list including any hidden items..


currentItem

public final QListWidgetItem currentItem()

Returns the current item.

See Also:
setCurrentItem

currentRow

public final int currentRow()

Returns the row of the current item..

Depending on the current selection mode, the row may also be selected.

See Also:
setCurrentRow

editItem

public final void editItem(QListWidgetItem item)

Starts editing the item if it is editable.


findItems

public final java.util.List<QListWidgetItem> findItems(java.lang.String text,
                                                       Qt.MatchFlag... flags)

Finds items with the text that matches the string text using the given flags.


findItems

public final java.util.List<QListWidgetItem> findItems(java.lang.String text,
                                                       Qt.MatchFlags flags)

Finds items with the text that matches the string text using the given flags.


indexFromItem

protected final QModelIndex indexFromItem(QListWidgetItem item)

Returns the QModelIndex assocated with the given item.


insertItem

public final void insertItem(int row,
                             java.lang.String label)

Inserts an item with the text label in the list widget at the position given by row.

See Also:
addItem

insertItem

public final void insertItem(int row,
                             QListWidgetItem item)

Inserts the item at the position in the list given by row.

See Also:
addItem

insertItems

public final void insertItems(int row,
                              java.util.List<java.lang.String> labels)

Inserts items from the list of labels into the list, starting at the given row.

See Also:
insertItem, addItem

isSortingEnabled

public final boolean isSortingEnabled()

Returns whether sorting is enabled.

If this property is true, sorting is enabled for the list; if the property is false, sorting is not enabled. The default value is false.


item

public final QListWidgetItem item(int row)

Returns the item that occupies the given row in the list if one has been set; otherwise returns 0.

See Also:
row

itemAt

public final QListWidgetItem itemAt(int x,
                                    int y)

Returns a pointer to the item at the coordinates (x, y).


itemAt

public final QListWidgetItem itemAt(QPoint p)

Returns a pointer to the item at the coordinates p.


itemFromIndex

protected final QListWidgetItem itemFromIndex(QModelIndex index)

Returns a pointer to the QListWidgetItem assocated with the given index.


itemWidget

public final QWidget itemWidget(QListWidgetItem item)

Returns the widget displayed in the given item.

See Also:
setItemWidget

items

protected final java.util.List<QListWidgetItem> items(QMimeData data)

Returns a list of pointers to the items contained in the data object. If the object was not created by a QListWidget in the same process, the list is empty.


openPersistentEditor

public final void openPersistentEditor(QListWidgetItem item)

Opens an editor for the given item. The editor remains open after editing.

See Also:
closePersistentEditor

removeItemWidget

public final void removeItemWidget(QListWidgetItem item)

Removes the widget set on the given item.


row

public final int row(QListWidgetItem item)

Returns the row containing the given item.

See Also:
item

scrollToItem

public final void scrollToItem(QListWidgetItem item)

Equivalent to scrollToItem(item, EnsureVisible).


scrollToItem

public final void scrollToItem(QListWidgetItem item,
                               QAbstractItemView.ScrollHint hint)

Scrolls the view if necessary to ensure that the item is visible. The hint parameter specifies more precisely where the item should be located after the operation.


selectedItems

public final java.util.List<QListWidgetItem> selectedItems()

Returns a list of all selected items in the list widget.


setCurrentItem

public final void setCurrentItem(QListWidgetItem item)

Sets the current item to item.

Depending on the current selection mode, the item may also be selected.

See Also:
currentItem

setCurrentRow

public final void setCurrentRow(int row)

Sets the row of the current item. to row.

Depending on the current selection mode, the row may also be selected.

See Also:
currentRow

setItemWidget

public final void setItemWidget(QListWidgetItem item,
                                QWidget widget)

Sets the widget to be displayed in the give item.

This function should only be used to display static content in the place of a list widget item. If you want to display custom dynamic content or implement a custom editor widget, use QListView and subclass QItemDelegate instead.

See Also:
itemWidget, Delegate Classes

setModel

@Deprecated
public final void setModel(QAbstractItemModel model)
Deprecated. 

Sets the model for the view to present.

Note: This function will also create and set a new selection model, replacing any previously set with setSelectionModel, but the old selection model will not be deleted.

Overrides:
setModel in class QAbstractItemView
See Also:
model, selectionModel, setSelectionModel

setSortingEnabled

public final void setSortingEnabled(boolean enable)

Sets whether sorting is enabled to enable.

If this property is true, sorting is enabled for the list; if the property is false, sorting is not enabled. The default value is false.

See Also:
isSortingEnabled

sortItems

public final void sortItems()

Equivalent to sortItems(Qt::AscendingOrder).


sortItems

public final void sortItems(Qt.SortOrder order)

Sorts all the items in the list widget according to the specified order.


takeItem

public final QListWidgetItem takeItem(int row)

Removes and returns the item from the given row in the list widget; otherwise returns 0.

Items removed from a list widget will not be managed by Qt, and will need to be deleted manually.

See Also:
insertItem, addItem

visualItemRect

public final QRect visualItemRect(QListWidgetItem item)

Returns the rectangle on the viewport occupied by the item at item.


dropEvent

protected void dropEvent(QDropEvent event)

This function is reimplemented for internal reasons.

Overrides:
dropEvent in class QListView
See Also:
startDrag

dropMimeData

protected boolean dropMimeData(int index,
                               QMimeData data,
                               Qt.DropAction action)

Handles the data supplied by a drag and drop operation that ended with the given action in the given index. Returns true if the data and action can be handled by the model; otherwise returns false.

See Also:
supportedDropActions

event

public boolean event(QEvent e)

This function is reimplemented for internal reasons.

Overrides:
event in class QListView
See Also:
QEvent::type

mimeData

protected QMimeData mimeData(java.util.List<QListWidgetItem> items)

Returns an object that contains a serialized description of the specified items. The format used to describe the items is obtained from the mimeTypes function.

If the list of items is empty, 0 is returned rather than a serialized empty list.


mimeTypes

protected java.util.List<java.lang.String> mimeTypes()

Returns a list of MIME types that can be used to describe a list of listwidget items.

See Also:
mimeData

supportedDropActions

protected Qt.DropActions supportedDropActions()

Returns the drop actions supported by this view.

See Also:
Qt::DropActions

fromNativePointer

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

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

Qt Jambi Home