Qt Jambi Home

com.trolltech.qt.gui
Class QListView

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
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface
Direct Known Subclasses:
QListWidget, QUndoView

public class QListView
extends QAbstractItemView

The QListView class provides a list or icon view onto a model.

A QListView presents items stored in a model, either as a simple non-hierarchical list, or as a collection of icons. This class is used to provide lists and icon views that were previously provided by the QListBox and QIconView classes, but using the more flexible approach provided by Qt's model/view architecture.

The QListView class is one of the Model/View Classes and is part of Qt's model/view framework.

This view does not display horizontal or vertical headers; to display a list of items with a horizontal header, use QTreeView instead.

QListView implements the interfaces defined by the QAbstractItemView class to allow it to display data provided by models derived from the QAbstractItemModel class.

Items in a list view can be displayed using one of two view modes: In ListMode, the items are displayed in the form of a simple list; in IconMode, the list view takes the form of an icon view in which the items are displayed with icons like files in a file manager. By default, the list view is in ListMode. To change the view mode, use the setViewMode function, and to determine the current view mode, use viewMode.

Items in these views are laid out in the direction specified by the flow of the list view. The items may be fixed in place, or allowed to move, depending on the view's movement state.

If the items in the model cannot be completely laid out in the direction of flow, they can be wrapped at the boundary of the view widget; this depends on isWrapping. This property is useful when the items are being represented by an icon view.

The resizeMode and layoutMode govern how and when the items are laid out. Items are spaced according to their spacing, and can exist within a notional grid of size specified by gridSize. The items can be rendered as large or small icons depending on their iconSize.

Screenshot of a Windows XP style list viewScreenshot of a Macintosh style table viewScreenshot of a Plastique style table view
A Windows XP style list view.A Macintosh style list view.A Plastique style list view.

Improving Performance

It is possible to give the view hints about the data it is handling in order to improve its performance when displaying large numbers of items. One approach that can be taken for views that are intended to display items with equal sizes is to set the uniformItemSizes property to true.

See Also:
View Classes, QTreeView, QTableView, QListWidget

Nested Class Summary
static class QListView.Flow
          Press link for info on QListView.Flow
static class QListView.LayoutMode
          Press link for info on QListView.LayoutMode
static class QListView.Movement
          Press link for info on QListView.Movement
static class QListView.ResizeMode
          Press link for info on QListView.ResizeMode
static class QListView.ViewMode
          Press link for info on 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.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.Signal1<java.util.List<QModelIndex>> 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
QListView()
          Equivalent to QListView(0).
QListView(QWidget parent)
          Creates a new QListView with the given parent to view a model.
 
Method Summary
 int batchSize()
          Returns the number of items laid out in each batch if layoutMode is set to Batched.
 void clearPropertyFlags()
          Clears the QListView-specific property flags.
protected  QSize contentsSize()
          
protected  void currentChanged(QModelIndex current, QModelIndex previous)
          

This slot is called when a new item becomes the current item.

protected  void dataChanged(QModelIndex topLeft, QModelIndex bottomRight)
          

This slot is called when items are changed in the model.

 void doItemsLayout()
          

protected  void dragLeaveEvent(QDragLeaveEvent e)
          

This function is called when the item being dragged leaves the view.

protected  void dragMoveEvent(QDragMoveEvent e)
          

This function is called continuously with the given event during a drag and drop operation over the widget.

protected  void dropEvent(QDropEvent e)
          

This function is called with the given event when a drop event occurs over the widget.

 boolean event(QEvent e)
          

This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

 QListView.Flow flow()
          Returns which direction the items layout should flow..
static QListView fromNativePointer(QNativePointer nativePointer)
          This function returns the QListView instance pointed to by nativePointer
 QSize gridSize()
          Returns the size of the layout grid.
protected  int horizontalOffset()
          

Returns the horizontal offset of the view.

 QModelIndex indexAt(QPoint p)
          

Returns the model index of the item at the viewport coordinates point.

protected  void internalDrag(Qt.DropAction... supportedActions)
          
protected  void internalDrag(Qt.DropActions supportedActions)
          
protected  void internalDrop(QDropEvent e)
          
protected  boolean isIndexHidden(QModelIndex index)
          

Returns true if the item referred to by the given index is hidden in the view, otherwise returns false.

 boolean isRowHidden(int row)
          Returns true if the row is hidden; otherwise returns false.
 boolean isSelectionRectVisible()
          Returns if the selection rectangle should be visible.
 boolean isWrapping()
          Returns whether the items layout should wrap..
 QListView.LayoutMode layoutMode()
          Returns whether the layout of items should happen immediately or be delayed..
 int modelColumn()
          Returns the column in the model that is visible.
protected  void mouseMoveEvent(QMouseEvent e)
          

This function is called with the given event when a mouse move event is sent to the widget.

protected  void mouseReleaseEvent(QMouseEvent e)
          

This function is called with the given event when a mouse button is released, after a mouse press event on the widget.

protected  QModelIndex moveCursor(QAbstractItemView.CursorAction cursorAction, Qt.KeyboardModifiers modifiers)
          Moves the cursor in the view according to the given cursorAction and keyboard modifiers specified by modifiers.
 QListView.Movement movement()
          Returns whether the items can be moved freely, are snapped to a grid, or cannot be moved at all..
protected  void paintEvent(QPaintEvent e)
          

This event handler can be reimplemented in a subclass to receive paint events (passed in arg__1), for the viewport widget.

protected  QRect rectForIndex(QModelIndex index)
          Returns the rectangle of the item at position index in the model.
 void reset()
          

Reset the internal state of the view.

protected  void resizeContents(int width, int height)
          
protected  void resizeEvent(QResizeEvent e)
          

This function is called with the given event when a resize event is sent to the widget.

 QListView.ResizeMode resizeMode()
          Returns whether the items are laid out again when the view is resized..
protected  void rowsAboutToBeRemoved(QModelIndex parent, int start, int end)
          

This slot is called when rows are about to be removed.

protected  void rowsInserted(QModelIndex parent, int start, int end)
          

This slot is called when rows are inserted.

protected  void scrollContentsBy(int dx, int dy)
          

This virtual handler is called when the scroll bars are moved by dx, dy, and consequently the viewport's contents should be scrolled accordingly.

 void scrollTo(QModelIndex index, QAbstractItemView.ScrollHint hint)
          Scrolls the view if necessary to ensure that the item at index is visible.
protected  java.util.List<QModelIndex> selectedIndexes()
          

This convenience function returns a list of all selected and non-hidden item indexes in the view.

protected  void selectionChanged(QItemSelection selected, QItemSelection deselected)
          

This slot is called when the selection is changed.

 void setBatchSize(int batchSize)
          Sets the number of items laid out in each batch if layoutMode is set to Batched to batchSize.
 void setFlow(QListView.Flow flow)
          Sets which direction the items layout should flow.
 void setGridSize(QSize size)
          Sets the size of the layout grid to size.
 void setLayoutMode(QListView.LayoutMode mode)
          Sets whether the layout of items should happen immediately or be delayed.
 void setModelColumn(int column)
          Sets the column in the model that is visible to column.
 void setMovement(QListView.Movement movement)
          Sets whether the items can be moved freely, are snapped to a grid, or cannot be moved at all.
protected  void setPositionForIndex(QPoint position, QModelIndex index)
          Sets the contents position of the item at index in the model to the given position.
 void setResizeMode(QListView.ResizeMode mode)
          Sets whether the items are laid out again when the view is resized.
 void setRootIndex(QModelIndex index)
          

Sets the root item to the item at the given index.

 void setRowHidden(int row, boolean hide)
          If hide is true, the given row will be hidden; otherwise the row will be shown.
protected  void setSelection(QRect rect, QItemSelectionModel.SelectionFlags command)
          Applies the selection command to the items in or touched by the rectangle, rect.
 void setSelectionRectVisible(boolean show)
          Sets if the selection rectangle should be visible to show.
 void setSpacing(int space)
          Sets the space between items in the layout to space.
 void setUniformItemSizes(boolean enable)
          Sets whether all items in the listview have the same size to enable.
 void setViewMode(QListView.ViewMode mode)
          Sets the view mode of the QListView.
 void setWordWrap(boolean on)
          Sets the item text word-wrapping policy to on.
 void setWrapping(boolean enable)
          Sets whether the items layout should wrap.
 int spacing()
          Returns the space between items in the layout.
protected  void startDrag(Qt.DropActions supportedActions)
          Starts a drag by calling drag->start() using the given supportedActions.
protected  void timerEvent(QTimerEvent e)
          

This function is called with the given event when a timer event is sent to the widget.

 boolean uniformItemSizes()
          Returns whether all items in the listview have the same size.
protected  void updateGeometries()
          

protected  int verticalOffset()
          

Returns the vertical offset of the view.

 QListView.ViewMode viewMode()
          Returns the view mode of the QListView..
protected  QStyleOptionViewItem viewOptions()
          

Returns a QStyleOptionViewItem structure populated with the view's palette, font, state, alignments etc.

 QRect visualRect(QModelIndex index)
          

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

protected  QRegion visualRegionForSelection(QItemSelection selection)
          

Returns the region from the viewport of the items in the given selection.

 boolean wordWrap()
          Returns the item text word-wrapping policy.
 
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, setModel, 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

indexesMoved

public final QSignalEmitter.Signal1<java.util.List<QModelIndex>> indexesMoved
Constructor Detail

QListView

public QListView()

Equivalent to QListView(0).


QListView

public QListView(QWidget parent)

Creates a new QListView with the given parent to view a model. Use setModel to set the model.

Method Detail

batchSize

public final int batchSize()

Returns the number of items laid out in each batch if layoutMode is set to Batched.

The default value is 100.

See Also:
setBatchSize

clearPropertyFlags

public final void clearPropertyFlags()

Clears the QListView-specific property flags. See viewMode.

Properties inherited from QAbstractItemView are not covered by the property flags. Specifically, dragEnabled and acceptDrops are computed by QListView when calling setMovement or setViewMode.


contentsSize

protected final QSize contentsSize()


flow

public final QListView.Flow flow()

Returns which direction the items layout should flow..

If this property is LeftToRight, the items will be laid out left to right. If the isWrapping property is true, the layout will wrap when it reaches the right side of the visible area. If this property is TopToBottom, the items will be laid out from the top of the visible area, wrapping when it reaches the bottom.

Setting this property when the view is visible will cause the items to be laid out again.

See Also:
setFlow, viewMode

gridSize

public final QSize gridSize()

Returns the size of the layout grid.

This property is the size of the grid in which the items are laid out. The default is an empty size which means that there is no grid and the layout is not done in a grid. Setting this property to a non-empty size switches on the grid layout. (When a grid layout is in force the spacing property is ignored.)

Setting this property when the view is visible will cause the items to be laid out again.

See Also:
setGridSize, viewMode

internalDrag

protected final void internalDrag(Qt.DropAction... supportedActions)


internalDrag

protected final void internalDrag(Qt.DropActions supportedActions)


internalDrop

protected final void internalDrop(QDropEvent e)


isRowHidden

public final boolean isRowHidden(int row)

Returns true if the row is hidden; otherwise returns false.


isSelectionRectVisible

public final boolean isSelectionRectVisible()

Returns if the selection rectangle should be visible.

If this property is true then the selection rectangle is visible; otherwise it will be hidden. Note that the selection rectangle will only be visible if the selection mode is in a mode where more than one item can be selected, i.e. it will not draw a selection rectangle if the selection mode is QAbstractItemView::SingleSelection.


isWrapping

public final boolean isWrapping()

Returns whether the items layout should wrap..

This property holds whether the layout should wrap when there is no more space in the visible area. The point at which the layout wraps depends on the flow property.

Setting this property when the view is visible will cause the items to be laid out again.

See Also:
viewMode

layoutMode

public final QListView.LayoutMode layoutMode()

Returns whether the layout of items should happen immediately or be delayed..

This property holds the layout mode for the items. When the mode is SinglePass (the default), the items are laid out all in one go. When the mode is Batched, the items are laid out in batches of batchSize items, while processing events. This makes it possible to instantly view and interact with the visible items while the rest are being laid out.

See Also:
setLayoutMode, viewMode

modelColumn

public final int modelColumn()

Returns the column in the model that is visible.

See Also:
setModelColumn

movement

public final QListView.Movement movement()

Returns whether the items can be moved freely, are snapped to a grid, or cannot be moved at all..

This property determines how the user can move the items in the view. Static means that the items can't be moved the user. Free means that the user can drag and drop the items to any position in the view. Snap means that the user can drag and drop the items, but only to the positions in a notional grid signified by the gridSize property.

Setting this property when the view is visible will cause the items to be laid out again.

See Also:
setMovement, gridSize, viewMode

rectForIndex

protected final QRect rectForIndex(QModelIndex index)

Returns the rectangle of the item at position index in the model. The rectangle is in contents coordinates.

See Also:
visualRect

resizeContents

protected final void resizeContents(int width,
                                    int height)


resizeMode

public final QListView.ResizeMode resizeMode()

Returns whether the items are laid out again when the view is resized..

If this property is Adjust, the items will be laid out again when the view is resized. If the value is Fixed, the items will not be laid out when the view is resized.

See Also:
setResizeMode, viewMode

setBatchSize

public final void setBatchSize(int batchSize)

Sets the number of items laid out in each batch if layoutMode is set to Batched to batchSize.

The default value is 100.

See Also:
batchSize

setFlow

public final void setFlow(QListView.Flow flow)

Sets which direction the items layout should flow. to flow.

If this property is LeftToRight, the items will be laid out left to right. If the isWrapping property is true, the layout will wrap when it reaches the right side of the visible area. If this property is TopToBottom, the items will be laid out from the top of the visible area, wrapping when it reaches the bottom.

Setting this property when the view is visible will cause the items to be laid out again.

See Also:
flow, viewMode

setGridSize

public final void setGridSize(QSize size)

Sets the size of the layout grid to size.

This property is the size of the grid in which the items are laid out. The default is an empty size which means that there is no grid and the layout is not done in a grid. Setting this property to a non-empty size switches on the grid layout. (When a grid layout is in force the spacing property is ignored.)

Setting this property when the view is visible will cause the items to be laid out again.

See Also:
gridSize, viewMode

setLayoutMode

public final void setLayoutMode(QListView.LayoutMode mode)

Sets whether the layout of items should happen immediately or be delayed. to mode.

This property holds the layout mode for the items. When the mode is SinglePass (the default), the items are laid out all in one go. When the mode is Batched, the items are laid out in batches of batchSize items, while processing events. This makes it possible to instantly view and interact with the visible items while the rest are being laid out.

See Also:
layoutMode, viewMode

setModelColumn

public final void setModelColumn(int column)

Sets the column in the model that is visible to column.

See Also:
modelColumn

setMovement

public final void setMovement(QListView.Movement movement)

Sets whether the items can be moved freely, are snapped to a grid, or cannot be moved at all. to movement.

This property determines how the user can move the items in the view. Static means that the items can't be moved the user. Free means that the user can drag and drop the items to any position in the view. Snap means that the user can drag and drop the items, but only to the positions in a notional grid signified by the gridSize property.

Setting this property when the view is visible will cause the items to be laid out again.

See Also:
movement, gridSize, viewMode

setPositionForIndex

protected final void setPositionForIndex(QPoint position,
                                         QModelIndex index)

Sets the contents position of the item at index in the model to the given position. If the list view's movement mode is Static, this function will have no effect.


setResizeMode

public final void setResizeMode(QListView.ResizeMode mode)

Sets whether the items are laid out again when the view is resized. to mode.

If this property is Adjust, the items will be laid out again when the view is resized. If the value is Fixed, the items will not be laid out when the view is resized.

See Also:
resizeMode, viewMode

setRowHidden

public final void setRowHidden(int row,
                               boolean hide)

If hide is true, the given row will be hidden; otherwise the row will be shown.

See Also:
isRowHidden

setSelectionRectVisible

public final void setSelectionRectVisible(boolean show)

Sets if the selection rectangle should be visible to show.

If this property is true then the selection rectangle is visible; otherwise it will be hidden. Note that the selection rectangle will only be visible if the selection mode is in a mode where more than one item can be selected, i.e. it will not draw a selection rectangle if the selection mode is QAbstractItemView::SingleSelection.

See Also:
isSelectionRectVisible

setSpacing

public final void setSpacing(int space)

Sets the space between items in the layout to space.

This property is the size of the empty space that is padded around an item in the layout.

Setting this property when the view is visible will cause the items to be laid out again.

See Also:
spacing, viewMode

setUniformItemSizes

public final void setUniformItemSizes(boolean enable)

Sets whether all items in the listview have the same size to enable.

This property should only be set to true if it is guaranteed that all items in the view have the same size. This enables the view to do some optimizations.

See Also:
uniformItemSizes

setViewMode

public final void setViewMode(QListView.ViewMode mode)

Sets the view mode of the QListView. to mode.

This property will change the other unset properties to conform with the set view mode. QListView-specific properties that have already been set will not be changed, unless clearPropertyFlags has been called.

Setting the view mode will enable or disable drag and drop based on the selected movement. For ListMode, the default movement is Static (drag and drop disabled); for IconMode, the default movement is Free (drag and drop enabled).

See Also:
viewMode, isWrapping, spacing, gridSize, flow, movement, resizeMode

setWordWrap

public final void setWordWrap(boolean on)

Sets the item text word-wrapping policy to on.

If this property is true then the item text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all. This property is false by default.

See Also:
wordWrap

setWrapping

public final void setWrapping(boolean enable)

Sets whether the items layout should wrap. to enable.

This property holds whether the layout should wrap when there is no more space in the visible area. The point at which the layout wraps depends on the flow property.

Setting this property when the view is visible will cause the items to be laid out again.

See Also:
isWrapping, viewMode

spacing

public final int spacing()

Returns the space between items in the layout.

This property is the size of the empty space that is padded around an item in the layout.

Setting this property when the view is visible will cause the items to be laid out again.

See Also:
setSpacing, viewMode

uniformItemSizes

public final boolean uniformItemSizes()

Returns whether all items in the listview have the same size.

This property should only be set to true if it is guaranteed that all items in the view have the same size. This enables the view to do some optimizations.

See Also:
setUniformItemSizes

viewMode

public final QListView.ViewMode viewMode()

Returns the view mode of the QListView..

This property will change the other unset properties to conform with the set view mode. QListView-specific properties that have already been set will not be changed, unless clearPropertyFlags has been called.

Setting the view mode will enable or disable drag and drop based on the selected movement. For ListMode, the default movement is Static (drag and drop disabled); for IconMode, the default movement is Free (drag and drop enabled).

See Also:
setViewMode, isWrapping, spacing, gridSize, flow, movement, resizeMode

wordWrap

public final boolean wordWrap()

Returns the item text word-wrapping policy.

If this property is true then the item text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all. This property is false by default.

See Also:
setWordWrap

currentChanged

protected void currentChanged(QModelIndex current,
                              QModelIndex previous)

This slot is called when a new item becomes the current item. The previous current item is specified by the previous index, and the new item by the current index.

If you want to know about changes to items see the dataChanged signal.

Overrides:
currentChanged in class QAbstractItemView

dataChanged

protected void dataChanged(QModelIndex topLeft,
                           QModelIndex bottomRight)

This slot is called when items are changed in the model. The changed items are those from topLeft to bottomRight inclusive. If just one item is changed topLeft == bottomRight.

Overrides:
dataChanged in class QAbstractItemView

doItemsLayout

public void doItemsLayout()

Overrides:
doItemsLayout in class QAbstractItemView

dragLeaveEvent

protected void dragLeaveEvent(QDragLeaveEvent e)

This function is called when the item being dragged leaves the view. The event describes the state of the drag and drop operation.

Overrides:
dragLeaveEvent in class QAbstractItemView
See Also:
QWidget::dragLeaveEvent

dragMoveEvent

protected void dragMoveEvent(QDragMoveEvent e)

This function is called continuously with the given event during a drag and drop operation over the widget. It can cause the view to scroll if, for example, the user drags a selection to view's right or bottom edge. In this case, the event will be accepted; otherwise it will be ignored.

Overrides:
dragMoveEvent in class QAbstractItemView
See Also:
dropEvent, startDrag

dropEvent

protected void dropEvent(QDropEvent e)

This function is called with the given event when a drop event occurs over the widget. If the model accepts the even position the drop event is accepted; otherwise it is ignored.

Overrides:
dropEvent in class QAbstractItemView
See Also:
startDrag

event

public boolean event(QEvent e)

This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

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

horizontalOffset

protected int horizontalOffset()

Returns the horizontal offset of the view.

In the base class this is a pure virtual function.

Specified by:
horizontalOffset in class QAbstractItemView
See Also:
verticalOffset

indexAt

public QModelIndex indexAt(QPoint p)

Returns the model index of the item at the viewport coordinates point.

In the base class this is a pure virtual function.

Specified by:
indexAt in class QAbstractItemView
See Also:
visualRect

isIndexHidden

protected boolean isIndexHidden(QModelIndex index)

Returns true if the item referred to by the given index is hidden in the view, otherwise returns false.

Hiding is a view specific feature. For example in TableView a column can be marked as hidden or a row in the TreeView.

In the base class this is a pure virtual function.

Specified by:
isIndexHidden in class QAbstractItemView

mouseMoveEvent

protected void mouseMoveEvent(QMouseEvent e)

This function is called with the given event when a mouse move event is sent to the widget. If a selection is in progress and new items are moved over the selection is extended; if a drag is in progress it is continued.

Overrides:
mouseMoveEvent in class QAbstractItemView
See Also:
QWidget::mouseMoveEvent

mouseReleaseEvent

protected void mouseReleaseEvent(QMouseEvent e)

This function is called with the given event when a mouse button is released, after a mouse press event on the widget. If a user presses the mouse inside your widget and then drags the mouse to another location before releasing the mouse button, your widget receives the release event. The function will emit the clicked signal if an item was being pressed.

Overrides:
mouseReleaseEvent in class QAbstractItemView
See Also:
QWidget::mouseReleaseEvent

moveCursor

protected QModelIndex moveCursor(QAbstractItemView.CursorAction cursorAction,
                                 Qt.KeyboardModifiers modifiers)

Moves the cursor in the view according to the given cursorAction and keyboard modifiers specified by modifiers.

In the base class this is a pure virtual function.

Specified by:
moveCursor in class QAbstractItemView

paintEvent

protected void paintEvent(QPaintEvent e)

This event handler can be reimplemented in a subclass to receive paint events (passed in arg__1), for the viewport widget.

Note: If you open a painter, make sure to open it on the viewport.

Overrides:
paintEvent in class QAbstractScrollArea
See Also:
QWidget::paintEvent

reset

public void reset()

Reset the internal state of the view.

Overrides:
reset in class QAbstractItemView

resizeEvent

protected void resizeEvent(QResizeEvent e)

This function is called with the given event when a resize event is sent to the widget.

Overrides:
resizeEvent in class QAbstractItemView
See Also:
QWidget::resizeEvent

rowsAboutToBeRemoved

protected void rowsAboutToBeRemoved(QModelIndex parent,
                                    int start,
                                    int end)

This slot is called when rows are about to be removed. The deleted rows are those under the given parent from start to end inclusive.

Overrides:
rowsAboutToBeRemoved in class QAbstractItemView
See Also:
rowsInserted

rowsInserted

protected void rowsInserted(QModelIndex parent,
                            int start,
                            int end)

This slot is called when rows are inserted. The new rows are those under the given parent from start to end inclusive. The base class implementation calls fetchMore() on the model to check for more data.

Overrides:
rowsInserted in class QAbstractItemView
See Also:
rowsAboutToBeRemoved

scrollContentsBy

protected void scrollContentsBy(int dx,
                                int dy)

This virtual handler is called when the scroll bars are moved by dx, dy, and consequently the viewport's contents should be scrolled accordingly.

The default implementation simply calls update on the entire viewport, subclasses can reimplement this handler for optimization purposes, or - like QScrollArea - to move a contents widget. The parameters dx and dy are there for convenience, so that the class knows how much should be scrolled (useful e.g. when doing pixel-shifts). You may just as well ignore these values and scroll directly to the position the scroll bars indicate.

Calling this function in order to scroll programmatically is an error, use the scroll bars instead (e.g. by calling QScrollBar::setValue() directly).

Overrides:
scrollContentsBy in class QAbstractScrollArea

scrollTo

public void scrollTo(QModelIndex index,
                     QAbstractItemView.ScrollHint hint)

Scrolls the view if necessary to ensure that the item at index is visible. The view will try to position the item according to the given hint.

In the base class this is a pure virtual function.

Specified by:
scrollTo in class QAbstractItemView

selectedIndexes

protected java.util.List<QModelIndex> selectedIndexes()

This convenience function returns a list of all selected and non-hidden item indexes in the view. The list contains no duplicates, and is not sorted.

The default implementation does nothing.

Overrides:
selectedIndexes in class QAbstractItemView
See Also:
QItemSelectionModel::selectedIndexes

selectionChanged

protected void selectionChanged(QItemSelection selected,
                                QItemSelection deselected)

This slot is called when the selection is changed. The previous selection (which may be empty), is specified by deselected, and the new selection by selected.

Overrides:
selectionChanged in class QAbstractItemView
See Also:
setSelection

setRootIndex

public void setRootIndex(QModelIndex index)

Sets the root item to the item at the given index.

Overrides:
setRootIndex in class QAbstractItemView
See Also:
rootIndex

setSelection

protected void setSelection(QRect rect,
                            QItemSelectionModel.SelectionFlags command)

Applies the selection command to the items in or touched by the rectangle, rect.

When implementing your own itemview setSelection should call selectionModel->select(selection, flags) where selection is either an empty QModelIndex or a QItemSelection that contains all items that are contained in rect.

Specified by:
setSelection in class QAbstractItemView
See Also:
selectionCommand, selectedIndexes

startDrag

protected void startDrag(Qt.DropActions supportedActions)

Starts a drag by calling drag->start() using the given supportedActions.

Overrides:
startDrag in class QAbstractItemView

timerEvent

protected void timerEvent(QTimerEvent e)

This function is called with the given event when a timer event is sent to the widget.

Overrides:
timerEvent in class QAbstractItemView
See Also:
QObject::timerEvent

updateGeometries

protected void updateGeometries()

Overrides:
updateGeometries in class QAbstractItemView

verticalOffset

protected int verticalOffset()

Returns the vertical offset of the view.

In the base class this is a pure virtual function.

Specified by:
verticalOffset in class QAbstractItemView
See Also:
horizontalOffset

viewOptions

protected QStyleOptionViewItem viewOptions()

Returns a QStyleOptionViewItem structure populated with the view's palette, font, state, alignments etc.

Overrides:
viewOptions in class QAbstractItemView

visualRect

public QRect visualRect(QModelIndex index)

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

If your item is displayed in several areas then visualRect should return the primary area that contains index and not the complete area that index might encompasses, touch or cause drawing.

In the base class this is a pure virtual function.

Specified by:
visualRect in class QAbstractItemView
See Also:
indexAt, visualRegionForSelection

visualRegionForSelection

protected QRegion visualRegionForSelection(QItemSelection selection)

Returns the region from the viewport of the items in the given selection.

In the base class this is a pure virtual function.

Specified by:
visualRegionForSelection in class QAbstractItemView
See Also:
visualRect, selectedIndexes

fromNativePointer

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

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

Qt Jambi Home