内容表

上一话题

QLineEdit

下一话题

QListWidget

QListView

QListView class provides a list or icon view onto a model. 更多

Inheritance diagram of PySide2.QtWidgets.QListView

继承者: QHelpIndexWidget , QListWidget , QUndoView

概要

函数

信号

详细描述

../../_images/windows-listview.png

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.

QListView class is one of the 模型/视图类 and is part of Qt’s 模型/视图框架 .

此视图不显示水平或垂直标题;要显示具有水平标题的项列表,使用 QTreeView 代替。

QListView implements the interfaces defined by the QAbstractItemView 类以允许它显示提供数据,通过模型派生自 QAbstractItemModel 类。

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() 状态。

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.

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() .

改善性能

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.

class QListView ( [ parent=None ] )
param parent

QWidget

创建新 QListView 采用给定 parent to view a model. Use setModel() to set the model.

PySide2.QtWidgets.QListView. Movement

常量

描述

QListView.Static

The items cannot be moved by the user.

QListView.Free

The items can be moved freely by the user.

QListView.Snap

The items snap to the specified grid when moved; see setGridSize() .

PySide2.QtWidgets.QListView. Flow

常量

描述

QListView.LeftToRight

The items are laid out in the view from the left to the right.

QListView.TopToBottom

The items are laid out in the view from the top to the bottom.

PySide2.QtWidgets.QListView. ResizeMode

常量

描述

QListView.Fixed

The items will only be laid out the first time the view is shown.

QListView.Adjust

The items will be laid out every time the view is resized.

PySide2.QtWidgets.QListView. LayoutMode

常量

描述

QListView.SinglePass

一次性布局所有项。

QListView.Batched

The items are laid out in batches of batchSize 项。

另请参阅

batchSize

PySide2.QtWidgets.QListView. ViewMode

常量

描述

QListView.ListMode

The items are laid out using TopToBottom flow, with Small size and Static movement

QListView.IconMode

The items are laid out using LeftToRight flow, with Large size and Free movement

PySide2.QtWidgets.QListView. batchSize ( )
返回类型

int

另请参阅

setBatchSize()

PySide2.QtWidgets.QListView. clearPropertyFlags ( )

清零 QListView -specific property flags. See viewMode .

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

PySide2.QtWidgets.QListView. contentsSize ( )
返回类型

QSize

PySide2.QtWidgets.QListView. flow ( )
返回类型

Flow

另请参阅

setFlow()

PySide2.QtWidgets.QListView. gridSize ( )
返回类型

QSize

另请参阅

setGridSize()

PySide2.QtWidgets.QListView. indexesMoved ( indexes )
参数

indexes QModelIndexList

PySide2.QtWidgets.QListView. isRowHidden ( row )
参数

row int

返回类型

bool

返回 true row 被隐藏;否则返回 false .

PySide2.QtWidgets.QListView. isSelectionRectVisible ( )
返回类型

bool

PySide2.QtWidgets.QListView. isWrapping ( )
返回类型

bool

PySide2.QtWidgets.QListView. itemAlignment ( )
返回类型

Alignment

PySide2.QtWidgets.QListView. layoutMode ( )
返回类型

LayoutMode

另请参阅

setLayoutMode()

PySide2.QtWidgets.QListView. modelColumn ( )
返回类型

int

另请参阅

setModelColumn()

PySide2.QtWidgets.QListView. movement ( )
返回类型

Movement

另请参阅

setMovement()

PySide2.QtWidgets.QListView. rectForIndex ( index )
参数

index QModelIndex

返回类型

QRect

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

另请参阅

visualRect()

PySide2.QtWidgets.QListView. resizeContents ( width , height )
参数
  • width int

  • height int

Resize the internal contents to width and height and set the scroll bar ranges accordingly.

PySide2.QtWidgets.QListView. resizeMode ( )
返回类型

ResizeMode

另请参阅

setResizeMode()

PySide2.QtWidgets.QListView. setBatchSize ( batchSize )
参数

batchSize int

另请参阅

batchSize()

PySide2.QtWidgets.QListView. setFlow ( flow )
参数

flow Flow

另请参阅

flow()

PySide2.QtWidgets.QListView. setGridSize ( size )
参数

size QSize

另请参阅

gridSize()

PySide2.QtWidgets.QListView. setItemAlignment ( alignment )
参数

alignment Alignment

另请参阅

itemAlignment()

PySide2.QtWidgets.QListView. setLayoutMode ( mode )
参数

mode LayoutMode

另请参阅

layoutMode()

PySide2.QtWidgets.QListView. setModelColumn ( column )
参数

column int

另请参阅

modelColumn()

PySide2.QtWidgets.QListView. setMovement ( movement )
参数

movement Movement

另请参阅

movement()

PySide2.QtWidgets.QListView. setPositionForIndex ( position , index )
参数
  • position QPoint

  • index QModelIndex

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 or its view mode is ListView , this function will have no effect.

PySide2.QtWidgets.QListView. setResizeMode ( mode )
参数

mode ResizeMode

另请参阅

resizeMode()

PySide2.QtWidgets.QListView. setRowHidden ( row , hide )
参数
  • row int

  • hide bool

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

另请参阅

isRowHidden()

PySide2.QtWidgets.QListView. setSelectionRectVisible ( show )
参数

show bool

PySide2.QtWidgets.QListView. setSpacing ( space )
参数

space int

另请参阅

spacing()

PySide2.QtWidgets.QListView. setUniformItemSizes ( enable )
参数

enable bool

PySide2.QtWidgets.QListView. setViewMode ( mode )
参数

mode ViewMode

另请参阅

viewMode()

PySide2.QtWidgets.QListView. setWordWrap ( on )
参数

on bool

另请参阅

wordWrap()

PySide2.QtWidgets.QListView. setWrapping ( enable )
参数

enable bool

另请参阅

isWrapping()

PySide2.QtWidgets.QListView. spacing ( )
返回类型

int

另请参阅

setSpacing()

PySide2.QtWidgets.QListView. uniformItemSizes ( )
返回类型

bool

PySide2.QtWidgets.QListView. viewMode ( )
返回类型

ViewMode

另请参阅

setViewMode()

PySide2.QtWidgets.QListView. wordWrap ( )
返回类型

bool

另请参阅

setWordWrap()