Home · Overviews · Examples 

QListView Class Reference
[com.trolltech.qt.gui module]

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

Inherits QAbstractItemView.

Inherited by QListWidget and QUndoView.


Detailed Description

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, and QListWidget.


Copyright © 2008 Trolltech Trademarks
Qt Jambi 4.3.4_01