QAbstractItemViewclass provides the basic functionality for item view classes. 更多 …
继承者: QHelpContentWidget , QHelpIndexWidget , QColumnView , QHeaderView , QListView , QListWidget , QTableView , QTableWidget , QTreeView , QTreeWidget , QUndoView
def
alternatingRowColors
()
def
autoScrollMargin
()
def
closePersistentEditor
(index)
def
currentIndex
()
def
defaultDropAction
()
def
dirtyRegionOffset
()
def
doAutoScroll
()
def
dragDropMode
()
def
dragDropOverwriteMode
()
def
dragEnabled
()
def
dropIndicatorPosition
()
def
editTriggers
()
def
executeDelayedItemsLayout
()
def
hasAutoScroll
()
def
horizontalScrollMode
()
def
horizontalStepsPerItem
()
def
iconSize
()
def
indexWidget
(index)
def
isPersistentEditorOpen
(index)
def
itemDelegate
()
def
itemDelegate
(index)
def
itemDelegateForColumn
(column)
def
itemDelegateForRow
(row)
def
model
()
def
openPersistentEditor
(index)
def
resetHorizontalScrollMode
()
def
resetVerticalScrollMode
()
def
rootIndex
()
def
scheduleDelayedItemsLayout
()
def
scrollDirtyRegion
(dx, dy)
def
selectionBehavior
()
def
selectionMode
()
def
selectionModel
()
def
setAlternatingRowColors
(enable)
def
setAutoScroll
(enable)
def
setAutoScrollMargin
(margin)
def
setDefaultDropAction
(dropAction)
def
setDirtyRegion
(region)
def
setDragDropMode
(behavior)
def
setDragDropOverwriteMode
(overwrite)
def
setDragEnabled
(enable)
def
setDropIndicatorShown
(enable)
def
setEditTriggers
(triggers)
def
setHorizontalScrollMode
(mode)
def
setHorizontalStepsPerItem
(steps)
def
setIconSize
(size)
def
setIndexWidget
(index, widget)
def
setItemDelegate
(delegate)
def
setItemDelegateForColumn
(column, delegate)
def
setItemDelegateForRow
(row, delegate)
def
setSelectionBehavior
(behavior)
def
setSelectionMode
(mode)
def
setState
(state)
def
setTabKeyNavigation
(enable)
def
setTextElideMode
(mode)
def
setVerticalScrollMode
(mode)
def
setVerticalStepsPerItem
(steps)
def
showDropIndicator
()
def
sizeHintForIndex
(index)
def
startAutoScroll
()
def
state
()
def
stopAutoScroll
()
def
tabKeyNavigation
()
def
textElideMode
()
def
verticalScrollMode
()
def
verticalStepsPerItem
()
def
closeEditor
(editor, hint)
def
commitData
(editor)
def
currentChanged
(current, previous)
def
dataChanged
(topLeft, bottomRight[, roles=list()])
def
doItemsLayout
()
def
edit
(index, trigger, event)
def
editorDestroyed
(editor)
def
horizontalOffset
()
def
horizontalScrollbarAction
(action)
def
horizontalScrollbarValueChanged
(value)
def
indexAt
(point)
def
isIndexHidden
(index)
def
keyboardSearch
(search)
def
moveCursor
(cursorAction, modifiers)
def
reset
()
def
rowsAboutToBeRemoved
(parent, start, end)
def
rowsInserted
(parent, start, end)
def
scrollTo
(index[, hint=EnsureVisible])
def
selectAll
()
def
selectedIndexes
()
def
selectionChanged
(selected, deselected)
def
selectionCommand
(index[, event=None])
def
setModel
(model)
def
setRootIndex
(index)
def
setSelection
(rect, command)
def
setSelectionModel
(selectionModel)
def
sizeHintForColumn
(column)
def
sizeHintForRow
(row)
def
startDrag
(supportedActions)
def
updateEditorData
()
def
updateEditorGeometries
()
def
updateGeometries
()
def
verticalOffset
()
def
verticalScrollbarAction
(action)
def
verticalScrollbarValueChanged
(value)
def
viewOptions
()
def
visualRect
(index)
def
visualRegionForSelection
(selection)
def
clearSelection
()
def
edit
(index)
def
scrollToBottom
()
def
scrollToTop
()
def
setCurrentIndex
(index)
def
update
(index)
def
activated
(index)
def
clicked
(index)
def
doubleClicked
(index)
def
entered
(index)
def
iconSizeChanged
(size)
def
pressed
(index)
def
viewportEntered
()
QAbstractItemViewclass is the base class for every standard view that uses aQAbstractItemModel.QAbstractItemViewis an abstract class and cannot itself be instantiated. It provides a standard interface for interoperating with models through the signals and slots mechanism, enabling subclasses to be kept up-to-date with changes to their models. This class provides standard support for keyboard and mouse navigation, viewport scrolling, item editing, and selections. The keyboard navigation implements this functionality:
键
功能
方向键
改变当前项并选择它。
Ctrl + 方向键
改变当前项但不选择它。
Shift + 方向键
更改当前项并选择它。先前选中项不会被取消选择。
Ctr+Space
切换当前项的选定。
Tab/Backtab
将当前项更改为下一/上一项。
Home/End
选择模型中的第一/最后项。
Page up/Page down
按视图中的可见行数向上/向下卷动展示行。
Ctrl+A
选择模型中的所有项。
注意,上表假定
selection mode允许操作。例如,无法选择项,若选定模式为NoSelection.
QAbstractItemViewclass is one of the 模型/视图类 and is part of Qt’s 模型/视图框架 .The view classes that inherit
QAbstractItemViewonly need to implement their own view-specific functionality, such as drawing items, returning the geometry of items, finding items, etc.
QAbstractItemViewprovides common slots such asedit()andsetCurrentIndex(). Many protected slots are also provided, includingdataChanged(),rowsInserted(),rowsAboutToBeRemoved(),selectionChanged(),和currentChanged().根项的返回通过
rootIndex(), and the current item bycurrentIndex(). To make sure that an item is visible usescrollTo().Some of
QAbstractItemView‘s functions are concerned with scrolling, for examplesetHorizontalScrollMode()andsetVerticalScrollMode(). To set the range of the scroll bars, you can, for example, reimplement the view’sresizeEvent()函数:def resizeEvent(self, event): horizontalScrollBar().setRange(0, realWidth - width()) ...注意,范围不更新,直到小部件被展示为止。
几个其它函数涉及选定控制;例如
setSelectionMode(),和setSelectionBehavior(). This class provides a default selection model to work with (selectionModel()), but this can be replaced by usingsetSelectionModel()with an instance ofQItemSelectionModel.要完全控制项的显示和编辑,可以指定委托采用
setItemDelegate().
QAbstractItemViewprovides a lot of protected functions. Some are concerned with editing, for example,edit(),和commitData(), whilst others are keyboard and mouse event handlers.注意
If you inherit
QAbstractItemViewand intend to update the contents of the viewport, you should use viewport->update()而不是update()因为所有描绘操作都发生在视口中。另请参阅
QAbstractItemView
(
[
parent=None
]
)
¶
- param parent
Constructs an abstract item view with the given
parent
.
PySide2.QtWidgets.QAbstractItemView.
SelectionMode
¶
此枚举指示视图如何响应用户选择:
|
常量 |
描述 |
|---|---|
|
QAbstractItemView.SingleSelection |
当用户选择项时,任何已选中项变为未选中。用户通过按下 Ctrl 键取消对选中项的选择是可能的,当点击选中项时。 |
|
QAbstractItemView.ContiguousSelection |
When the user selects an item in the usual way, the selection is cleared and the new item selected. However, if the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected or unselected, depending on the state of the clicked item. |
|
QAbstractItemView.ExtendedSelection |
When the user selects an item in the usual way, the selection is cleared and the new item selected. However, if the user presses the Ctrl key when clicking on an item, the clicked item gets toggled and all other items are left untouched. If the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected or unselected, depending on the state of the clicked item. Multiple items can be selected by dragging the mouse over them. |
|
QAbstractItemView.MultiSelection |
When the user selects an item in the usual way, the selection status of that item is toggled and the other items are left alone. Multiple items can be toggled by dragging the mouse over them. |
|
QAbstractItemView.NoSelection |
无法选择项。 |
The most commonly used modes are and .
PySide2.QtWidgets.QAbstractItemView.
SelectionBehavior
¶
|
常量 |
描述 |
|---|---|
|
QAbstractItemView.SelectItems |
选择单个项。 |
|
QAbstractItemView.SelectRows |
仅选择行。 |
|
QAbstractItemView.SelectColumns |
仅选择列。 |
PySide2.QtWidgets.QAbstractItemView.
ScrollHint
¶
|
常量 |
描述 |
|---|---|
|
QAbstractItemView.EnsureVisible |
卷动以确保项可见。 |
|
QAbstractItemView.PositionAtTop |
卷动以将项放置在视口顶部。 |
|
QAbstractItemView.PositionAtBottom |
卷动以定位到视口底部项。 |
|
QAbstractItemView.PositionAtCenter |
卷动以定位到视口中心项。 |
PySide2.QtWidgets.QAbstractItemView.
EditTrigger
¶
此枚举描述将初始项编辑的动作。
|
常量 |
描述 |
|---|---|
|
QAbstractItemView.NoEditTriggers |
没有编辑可能。 |
|
QAbstractItemView.CurrentChanged |
开始编辑每当当前项改变时。 |
|
QAbstractItemView.DoubleClicked |
开始编辑当双击项时。 |
|
QAbstractItemView.SelectedClicked |
开始编辑当点击已选中项时。 |
|
QAbstractItemView.EditKeyPressed |
开始编辑当在项上按下平台编辑键时。 |
|
QAbstractItemView.AnyKeyPressed |
开始编辑当在项上按下任意键时。 |
|
QAbstractItemView.AllEditTriggers |
开始编辑对于上述所有动作。 |
PySide2.QtWidgets.QAbstractItemView.
ScrollMode
¶
Describes how the scrollbar should behave. When setting the scroll mode to the single step size will adjust automatically unless it was set explicitly using
setSingleStep()
。可以通过将单步大小设为-1 以还原自动调节。
|
常量 |
描述 |
|---|---|
|
QAbstractItemView.ScrollPerItem |
视图每次卷动内容一项。 |
|
QAbstractItemView.ScrollPerPixel |
视图每次卷动内容一像素。 |
PySide2.QtWidgets.QAbstractItemView.
DragDropMode
¶
描述视图可以行动的各种拖放事件。默认情况下,视图不支持拖曳或掉落 (
NoDragDrop
).
|
常量 |
描述 |
|---|---|
|
QAbstractItemView.NoDragDrop |
不支持拖曳或掉落。 |
|
QAbstractItemView.DragOnly |
视图支持拖曳自己的项 |
|
QAbstractItemView.DropOnly |
视图接受掉落 |
|
QAbstractItemView.DragDrop |
视图支持拖拽和掉落两者 |
|
QAbstractItemView.InternalMove |
视图接受移动 ( 非拷贝 ) 操作仅来自自身。 |
注意,使用模型需要提供对拖放操作的支持。
PySide2.QtWidgets.QAbstractItemView.
CursorAction
¶
此枚举描述在项之间导航的不同方式,
|
常量 |
描述 |
|---|---|
|
QAbstractItemView.MoveUp |
移至当前项的上方项。 |
|
QAbstractItemView.MoveDown |
移至当前项的下方项。 |
|
QAbstractItemView.MoveLeft |
移动到当前项的左侧项。 |
|
QAbstractItemView.MoveRight |
移动到当前项的右侧项。 |
|
QAbstractItemView.MoveHome |
移至左上角项。 |
|
QAbstractItemView.MoveEnd |
移动到右下角项。 |
|
QAbstractItemView.MovePageUp |
移至当前项上一页。 |
|
QAbstractItemView.MovePageDown |
移至当前项下一页。 |
|
QAbstractItemView.MoveNext |
移至当前项之后项。 |
|
QAbstractItemView.MovePrevious |
移至当前项之前项。 |
另请参阅
PySide2.QtWidgets.QAbstractItemView.
State
¶
描述视图可以处于的不同状态。通常,这只对重实现自己的视图感兴趣。
|
常量 |
描述 |
|---|---|
|
QAbstractItemView.NoState |
这是默认状态。 |
|
QAbstractItemView.DraggingState |
用户正在拖曳项。 |
|
QAbstractItemView.DragSelectingState |
用户正在选择项。 |
|
QAbstractItemView.EditingState |
用户正在 Widget 编辑器中编辑项。 |
|
QAbstractItemView.ExpandingState |
用户正在打开项分支。 |
|
QAbstractItemView.CollapsingState |
用户正在关闭项分支。 |
|
QAbstractItemView.AnimatingState |
项视图正在履行动画。 |
PySide2.QtWidgets.QAbstractItemView.
DropIndicatorPosition
¶
此枚举指示掉落指示器相对当前鼠标位置的索引位置:
|
常量 |
描述 |
|---|---|
|
QAbstractItemView.OnItem |
项将掉落在索引处。 |
|
QAbstractItemView.AboveItem |
项将掉落在索引上方。 |
|
QAbstractItemView.BelowItem |
项将掉落在索引下方。 |
|
QAbstractItemView.OnViewport |
项将掉落在没有项的视口区域。各视图处理视口掉落项的方式,从属正使用的底层模型行为。 |
PySide2.QtWidgets.QAbstractItemView.
activated
(
index
)
¶
index
–
QModelIndex
PySide2.QtWidgets.QAbstractItemView.
alternatingRowColors
(
)
¶
bool
PySide2.QtWidgets.QAbstractItemView.
autoScrollMargin
(
)
¶
int
PySide2.QtWidgets.QAbstractItemView.
clearSelection
(
)
¶
Deselects all selected items. The current index will not be changed.
PySide2.QtWidgets.QAbstractItemView.
clicked
(
index
)
¶
index
–
QModelIndex
PySide2.QtWidgets.QAbstractItemView.
closeEditor
(
editor
,
hint
)
¶
editor
–
QWidget
hint
–
EndEditHint
关闭给定
editor
, and releases it. The
hint
is used to specify how the view should respond to the end of the editing operation. For example, the hint may indicate that the next item in the view should be opened for editing.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
closePersistentEditor
(
index
)
¶
index
–
QModelIndex
Closes the persistent editor for the item at the given
index
.
PySide2.QtWidgets.QAbstractItemView.
commitData
(
editor
)
¶
editor
–
QWidget
提交数据在
editor
到模型。
另请参阅
PySide2.QtWidgets.QAbstractItemView.
currentChanged
(
current
,
上一
)
¶
current
–
QModelIndex
上一
–
QModelIndex
This slot is called when a new item becomes the current item. The previous current item is specified by the
上一
index, and the new item by the
current
index.
If you want to know about changes to items see the
dataChanged()
信号。
PySide2.QtWidgets.QAbstractItemView.
currentIndex
(
)
¶
QModelIndex
Returns the model index of the current item.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
dataChanged
(
topLeft
,
bottomRight
[
,
roles=list()
]
)
¶
topLeft
–
QModelIndex
bottomRight
–
QModelIndex
roles –
This slot is called when items with the given
roles
are changed in the model. The changed items are those from
topLeft
to
bottomRight
inclusive. If just one item is changed
topLeft
==
bottomRight
.
roles
which have been changed can either be an empty container (meaning everything has changed), or a non-empty container with the subset of roles which have changed.
注意
:
ToolTipRole
is not honored by in the views provided by Qt.
PySide2.QtWidgets.QAbstractItemView.
defaultDropAction
(
)
¶
DropAction
PySide2.QtWidgets.QAbstractItemView.
dirtyRegionOffset
(
)
¶
QPoint
Returns the offset of the dirty regions in the view.
若使用
scrollDirtyRegion()
and implement a
paintEvent()
in a subclass of
QAbstractItemView
, you should translate the area given by the paint event with the offset returned from this function.
PySide2.QtWidgets.QAbstractItemView.
doAutoScroll
(
)
¶
PySide2.QtWidgets.QAbstractItemView.
doItemsLayout
(
)
¶
This function is intended to lay out the items in the view. The default implementation just calls
updateGeometries()
and updates the viewport.
PySide2.QtWidgets.QAbstractItemView.
doubleClicked
(
index
)
¶
index
–
QModelIndex
PySide2.QtWidgets.QAbstractItemView.
dragDropMode
(
)
¶
另请参阅
PySide2.QtWidgets.QAbstractItemView.
dragDropOverwriteMode
(
)
¶
bool
PySide2.QtWidgets.QAbstractItemView.
dragEnabled
(
)
¶
bool
另请参阅
PySide2.QtWidgets.QAbstractItemView.
dropIndicatorPosition
(
)
¶
Returns the position of the drop indicator in relation to the closest item.
PySide2.QtWidgets.QAbstractItemView.
edit
(
index
)
¶
index
–
QModelIndex
Starts editing the item corresponding to the given
index
若它可编辑。
Note that this function does not change the current index. Since the current index defines the next and previous items to edit, users may find that keyboard navigation does not work as expected. To provide consistent navigation behavior, call
setCurrentIndex()
before this function with the same model index.
另请参阅
flags()
PySide2.QtWidgets.QAbstractItemView.
edit
(
index
,
trigger
,
event
)
¶
index
–
QModelIndex
trigger
–
EditTrigger
event
–
QEvent
bool
Starts editing the item at
index
, creating an editor if necessary, and returns
true
if the view’s
State
现为
EditingState
;否则返回
false
.
The action that caused the editing process is described by
trigger
, and the associated event is specified by
event
.
Editing can be forced by specifying the
trigger
to be
AllEditTriggers
.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
editTriggers
(
)
¶
EditTriggers
另请参阅
PySide2.QtWidgets.QAbstractItemView.
editorDestroyed
(
editor
)
¶
editor
–
QObject
This function is called when the given
editor
has been destroyed.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
entered
(
index
)
¶
index
–
QModelIndex
PySide2.QtWidgets.QAbstractItemView.
executeDelayedItemsLayout
(
)
¶
Executes the scheduled layouts without waiting for the event processing to begin.
PySide2.QtWidgets.QAbstractItemView.
hasAutoScroll
(
)
¶
bool
PySide2.QtWidgets.QAbstractItemView.
horizontalOffset
(
)
¶
int
Returns the horizontal offset of the view.
在基类中,这是纯虚函数。
另请参阅
PySide2.QtWidgets.QAbstractItemView.
horizontalScrollMode
(
)
¶
PySide2.QtWidgets.QAbstractItemView.
horizontalScrollbarAction
(
action
)
¶
action
–
int
PySide2.QtWidgets.QAbstractItemView.
horizontalScrollbarValueChanged
(
value
)
¶
value
–
int
PySide2.QtWidgets.QAbstractItemView.
horizontalStepsPerItem
(
)
¶
int
注意
此函数被弃用。
Returns the horizontal scroll bar’s steps per item.
PySide2.QtWidgets.QAbstractItemView.
iconSize
(
)
¶
QSize
另请参阅
PySide2.QtWidgets.QAbstractItemView.
iconSizeChanged
(
size
)
¶
size
–
QSize
PySide2.QtWidgets.QAbstractItemView.
indexAt
(
point
)
¶
point
–
QPoint
QModelIndex
Returns the model index of the item at the viewport coordinates
point
.
在基类中,这是纯虚函数。
另请参阅
PySide2.QtWidgets.QAbstractItemView.
indexWidget
(
index
)
¶
index
–
QModelIndex
返回用于项的 Widget 在给定
index
.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
isIndexHidden
(
index
)
¶
index
–
QModelIndex
bool
返回
true
若项引用通过给定
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.
在基类中,这是纯虚函数。
PySide2.QtWidgets.QAbstractItemView.
isPersistentEditorOpen
(
index
)
¶
index
–
QModelIndex
bool
返回项是否打开持久编辑器在索引
index
.
PySide2.QtWidgets.QAbstractItemView.
itemDelegate
(
)
¶
Returns the item delegate used by this view and model. This is either one set with
setItemDelegate()
, or the default one.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
itemDelegate
(
index
)
¶
index
–
QModelIndex
Returns the item delegate used by this view and model for the given
index
.
PySide2.QtWidgets.QAbstractItemView.
itemDelegateForColumn
(
column
)
¶
column
–
int
Returns the item delegate used by this view and model for the given
column
. You can call
itemDelegate()
to get a pointer to the current delegate for a given index.
PySide2.QtWidgets.QAbstractItemView.
itemDelegateForRow
(
row
)
¶
row
–
int
Returns the item delegate used by this view and model for the given
row
,或
None
if no delegate has been assigned. You can call
itemDelegate()
to get a pointer to the current delegate for a given index.
PySide2.QtWidgets.QAbstractItemView.
keyboardSearch
(
search
)
¶
search – unicode
Moves to and selects the item best matching the string
search
. If no item is found nothing happens.
In the default implementation, the search is reset if
search
is empty, or the time interval since the last search has exceeded
keyboardInputInterval()
.
PySide2.QtWidgets.QAbstractItemView.
model
(
)
¶
QAbstractItemModel
Returns the model that this view is presenting.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
moveCursor
(
cursorAction
,
modifiers
)
¶
cursorAction
–
CursorAction
modifiers
–
KeyboardModifiers
QModelIndex
返回
QModelIndex
对象指向下一视图对象,基于给定
cursorAction
and keyboard modifiers specified by
modifiers
.
在基类中,这是纯虚函数。
PySide2.QtWidgets.QAbstractItemView.
openPersistentEditor
(
index
)
¶
index
–
QModelIndex
Opens a persistent editor on the item at the given
index
. If no editor exists, the delegate will create a new editor.
PySide2.QtWidgets.QAbstractItemView.
pressed
(
index
)
¶
index
–
QModelIndex
PySide2.QtWidgets.QAbstractItemView.
reset
(
)
¶
重置视图的内部状态。
警告
This function will reset open editors, scroll bar positions, selections, etc. Existing changes will not be committed. If you would like to save your changes when resetting the view, you can reimplement this function, commit your changes, and then call the superclass’ implementation.
PySide2.QtWidgets.QAbstractItemView.
resetHorizontalScrollMode
(
)
¶
PySide2.QtWidgets.QAbstractItemView.
resetVerticalScrollMode
(
)
¶
PySide2.QtWidgets.QAbstractItemView.
rootIndex
(
)
¶
QModelIndex
Returns the model index of the model’s root item. The root item is the parent item to the view’s toplevel items. The root can be invalid.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
rowsAboutToBeRemoved
(
parent
,
start
,
end
)
¶
parent
–
QModelIndex
start
–
int
end
–
int
This slot is called when rows are about to be removed. The deleted rows are those under the given
parent
from
start
to
end
包含在内。
另请参阅
PySide2.QtWidgets.QAbstractItemView.
rowsInserted
(
parent
,
start
,
end
)
¶
parent
–
QModelIndex
start
–
int
end
–
int
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.
PySide2.QtWidgets.QAbstractItemView.
scheduleDelayedItemsLayout
(
)
¶
Schedules a layout of the items in the view to be executed when the event processing starts.
Even if is called multiple times before events are processed, the view will only do the layout once.
PySide2.QtWidgets.QAbstractItemView.
scrollDirtyRegion
(
dx
,
dy
)
¶
dx
–
int
dy
–
int
Prepares the view for scrolling by (
dx
,``dy`` ) pixels by moving the dirty regions in the opposite direction. You only need to call this function if you are implementing a scrolling viewport in your view subclass.
若实现
scrollContentsBy()
in a subclass of
QAbstractItemView
, call this function before you call
scroll()
on the viewport. Alternatively, just call
update()
.
PySide2.QtWidgets.QAbstractItemView.
scrollTo
(
index
[
,
hint=EnsureVisible
]
)
¶
index
–
QModelIndex
hint
–
ScrollHint
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
.
在基类中,这是纯虚函数。
PySide2.QtWidgets.QAbstractItemView.
scrollToBottom
(
)
¶
卷动视图到底部。
另请参阅
PySide2.QtWidgets.QAbstractItemView.
scrollToTop
(
)
¶
卷动视图到顶部。
PySide2.QtWidgets.QAbstractItemView.
selectAll
(
)
¶
Selects all items in the view. This function will use the selection behavior set on the view when selecting.
PySide2.QtWidgets.QAbstractItemView.
selectedIndexes
(
)
¶
QModelIndexList
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.
另请参阅
selectedIndexes()
PySide2.QtWidgets.QAbstractItemView.
selectionBehavior
(
)
¶
PySide2.QtWidgets.QAbstractItemView.
selectionChanged
(
selected
,
deselected
)
¶
selected
–
QItemSelection
deselected
–
QItemSelection
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
.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
selectionCommand
(
index
[
,
event=None
]
)
¶
index
–
QModelIndex
event
–
QEvent
SelectionFlags
Returns the SelectionFlags to be used when updating a selection with to include the
index
specified. The
event
is a user input event, such as a mouse or keyboard event.
Reimplement this function to define your own selection behavior.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
selectionMode
(
)
¶
另请参阅
PySide2.QtWidgets.QAbstractItemView.
selectionModel
(
)
¶
QItemSelectionModel
返回当前选定模型。
PySide2.QtWidgets.QAbstractItemView.
setAlternatingRowColors
(
enable
)
¶
enable
–
bool
PySide2.QtWidgets.QAbstractItemView.
setAutoScroll
(
enable
)
¶
enable
–
bool
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setAutoScrollMargin
(
margin
)
¶
margin
–
int
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setCurrentIndex
(
index
)
¶
index
–
QModelIndex
把当前项设为项在
index
.
除非当前选定方式为
NoSelection
,项也会被选中。注意:此函数还会更新用户履行任何新选定的起始位置。
要把项设为当前项而不选择它,调用
selectionModel()->setCurrentIndex(index,
QItemSelectionModel::NoUpdate);
PySide2.QtWidgets.QAbstractItemView.
setDefaultDropAction
(
dropAction
)
¶
dropAction
–
DropAction
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setDirtyRegion
(
region
)
¶
region
–
QRegion
Marks the given
region
as dirty and schedules it to be updated. You only need to call this function if you are implementing your own view subclass.
PySide2.QtWidgets.QAbstractItemView.
setDragDropMode
(
behavior
)
¶
behavior
–
DragDropMode
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setDragDropOverwriteMode
(
overwrite
)
¶
overwrite
–
bool
PySide2.QtWidgets.QAbstractItemView.
setDragEnabled
(
enable
)
¶
enable
–
bool
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setDropIndicatorShown
(
enable
)
¶
enable
–
bool
PySide2.QtWidgets.QAbstractItemView.
setEditTriggers
(
triggers
)
¶
triggers
–
EditTriggers
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setHorizontalScrollMode
(
mode
)
¶
mode
–
ScrollMode
PySide2.QtWidgets.QAbstractItemView.
setHorizontalStepsPerItem
(
steps
)
¶
steps
–
int
注意
此函数被弃用。
Sets the horizontal scroll bar’s steps per item to
steps
.
This is the number of steps used by the horizontal scroll bar to represent the width of an item.
Note that if the view has a horizontal header, the item steps will be ignored and the header section size will be used instead.
PySide2.QtWidgets.QAbstractItemView.
setIconSize
(
size
)
¶
size
–
QSize
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setIndexWidget
(
index
,
widget
)
¶
index
–
QModelIndex
widget
–
QWidget
设置给定
widget
on the item at the given
index
, passing the ownership of the widget to the viewport.
若
index
is invalid (e.g., if you pass the root index), this function will do nothing.
给定
widget
‘s
autoFillBackground
property must be set to true, otherwise the widget’s background will be transparent, showing both the model data and the item at the given
index
.
If index widget A is replaced with index widget B, index widget A will be deleted. For example, in the code snippet below, the
QLineEdit
object will be deleted.
setIndexWidget(index, QLineEdit())
...
setIndexWidget(index, QTextEdit())
This function should only be used to display static content within the visible area corresponding to an item of data. If you want to display custom dynamic content or implement a custom editor widget, subclass
QStyledItemDelegate
代替。
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setItemDelegate
(
delegate
)
¶
delegate
–
QAbstractItemDelegate
Sets the item delegate for this view and its model to
delegate
. This is useful if you want complete control over the editing and display of items.
任何现有委托将被移除,但不被删除。
QAbstractItemView
未拥有所有权对于
delegate
.
警告
You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the
closeEditor()
signal, and attempt to access, modify or close an editor that has already been closed.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setItemDelegateForColumn
(
column
,
delegate
)
¶
column
–
int
delegate
–
QAbstractItemDelegate
Sets the given item
delegate
used by this view and model for the given
column
. All items on
column
will be drawn and managed by
delegate
instead of using the default delegate (i.e.,
itemDelegate()
).
Any existing column delegate for
column
will be removed, but not deleted.
QAbstractItemView
未拥有所有权对于
delegate
.
注意
If a delegate has been assigned to both a row and a column, the row delegate will take precedence and manage the intersecting cell index.
警告
You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the
closeEditor()
signal, and attempt to access, modify or close an editor that has already been closed.
PySide2.QtWidgets.QAbstractItemView.
setItemDelegateForRow
(
row
,
delegate
)
¶
row
–
int
delegate
–
QAbstractItemDelegate
Sets the given item
delegate
used by this view and model for the given
row
. All items on
row
will be drawn and managed by
delegate
instead of using the default delegate (i.e.,
itemDelegate()
).
Any existing row delegate for
row
will be removed, but not deleted.
QAbstractItemView
未拥有所有权对于
delegate
.
注意
If a delegate has been assigned to both a row and a column, the row delegate (i.e., this delegate) will take precedence and manage the intersecting cell index.
警告
You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the
closeEditor()
signal, and attempt to access, modify or close an editor that has already been closed.
PySide2.QtWidgets.QAbstractItemView.
setModel
(
model
)
¶
model
–
QAbstractItemModel
设置
model
for the view to present.
This function will create and set a new selection model, replacing any model that was previously set with
setSelectionModel()
. However, the old selection model will not be deleted as it may be shared between several views. We recommend that you delete the old selection model if it is no longer required. This is done with the following code:
m = view->selectionModel()
view->setModel(model())
del m
If both the old model and the old selection model do not have parents, or if their parents are long-lived objects, it may be preferable to call their
deleteLater()
functions to explicitly delete them.
The view does not take ownership of the model unless it is the model’s parent object because the model may be shared between many different views.
PySide2.QtWidgets.QAbstractItemView.
setRootIndex
(
index
)
¶
index
–
QModelIndex
Sets the root item to the item at the given
index
.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setSelection
(
rect
,
command
)
¶
rect
–
QRect
command
–
SelectionFlags
Applies the selection
flags
to the items in or touched by the rectangle,
rect
.
When implementing your own itemview should call
selectionModel()
->select(selection, flags) where selection is either an empty
QModelIndex
或
QItemSelection
that contains all items that are contained in
rect
.
PySide2.QtWidgets.QAbstractItemView.
setSelectionBehavior
(
behavior
)
¶
behavior
–
SelectionBehavior
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setSelectionMode
(
mode
)
¶
mode
–
SelectionMode
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setSelectionModel
(
selectionModel
)
¶
selectionModel
–
QItemSelectionModel
Sets the current selection model to the given
selectionModel
.
Note that, if you call
setModel()
after this function, the given
selectionModel
will be replaced by one created by the view.
注意
It is up to the application to delete the old selection model if it is no longer needed; i.e., if it is not being used by other views. This will happen automatically when its parent object is deleted. However, if it does not have a parent, or if the parent is a long-lived object, it may be preferable to call its
deleteLater()
function to explicitly delete it.
PySide2.QtWidgets.QAbstractItemView.
setState
(
state
)
¶
state
–
State
Sets the item view’s state to the given
state
.
另请参阅
enable
–
bool
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setTextElideMode
(
mode
)
¶
mode
–
TextElideMode
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setVerticalScrollMode
(
mode
)
¶
mode
–
ScrollMode
另请参阅
PySide2.QtWidgets.QAbstractItemView.
setVerticalStepsPerItem
(
steps
)
¶
steps
–
int
注意
此函数被弃用。
Sets the vertical scroll bar’s steps per item to
steps
.
This is the number of steps used by the vertical scroll bar to represent the height of an item.
Note that if the view has a vertical header, the item steps will be ignored and the header section size will be used instead.
PySide2.QtWidgets.QAbstractItemView.
showDropIndicator
(
)
¶
bool
PySide2.QtWidgets.QAbstractItemView.
sizeHintForColumn
(
column
)
¶
column
–
int
int
Returns the width size hint for the specified
column
or -1 if there is no model.
This function is used in views with a horizontal header to find the size hint for a header section based on the contents of the given
column
.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
sizeHintForIndex
(
index
)
¶
index
–
QModelIndex
QSize
Returns the size hint for the item with the specified
index
or an invalid size for invalid indexes.
PySide2.QtWidgets.QAbstractItemView.
sizeHintForRow
(
row
)
¶
row
–
int
int
Returns the height size hint for the specified
row
or -1 if there is no model.
The returned height is calculated using the size hints of the given
row
‘s items, i.e. the returned value is the maximum height among the items. Note that to control the height of a row, you must reimplement the
sizeHint()
函数。
This function is used in views with a vertical header to find the size hint for a header section based on the contents of the given
row
.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
startAutoScroll
(
)
¶
PySide2.QtWidgets.QAbstractItemView.
startDrag
(
supportedActions
)
¶
supportedActions
–
DropActions
Starts a drag by calling drag->exec() using the given
supportedActions
.
PySide2.QtWidgets.QAbstractItemView.
state
(
)
¶
Returns the item view’s state.
另请参阅
PySide2.QtWidgets.QAbstractItemView.
stopAutoScroll
(
)
¶
bool
PySide2.QtWidgets.QAbstractItemView.
textElideMode
(
)
¶
TextElideMode
另请参阅
PySide2.QtWidgets.QAbstractItemView.
update
(
index
)
¶
index
–
QModelIndex
Updates the area occupied by the given
index
.
PySide2.QtWidgets.QAbstractItemView.
updateEditorData
(
)
¶
Updates the data shown in the open editor widgets in the view.
PySide2.QtWidgets.QAbstractItemView.
updateEditorGeometries
(
)
¶
Updates the geometry of the open editor widgets in the view.
PySide2.QtWidgets.QAbstractItemView.
updateGeometries
(
)
¶
Updates the geometry of the child widgets of the view.
PySide2.QtWidgets.QAbstractItemView.
verticalOffset
(
)
¶
int
返回视图的垂直偏移。
在基类中,这是纯虚函数。
另请参阅
PySide2.QtWidgets.QAbstractItemView.
verticalScrollMode
(
)
¶
PySide2.QtWidgets.QAbstractItemView.
verticalScrollbarAction
(
action
)
¶
action
–
int
PySide2.QtWidgets.QAbstractItemView.
verticalScrollbarValueChanged
(
value
)
¶
value
–
int
PySide2.QtWidgets.QAbstractItemView.
verticalStepsPerItem
(
)
¶
int
注意
此函数被弃用。
Returns the vertical scroll bar’s steps per item.
PySide2.QtWidgets.QAbstractItemView.
viewOptions
(
)
¶
返回
QStyleOptionViewItem
structure populated with the view’s palette, font, state, alignments etc.
PySide2.QtWidgets.QAbstractItemView.
viewportEntered
(
)
¶
PySide2.QtWidgets.QAbstractItemView.
visualRect
(
index
)
¶
index
–
QModelIndex
QRect
返回项所占据的视口矩形在
index
.
If your item is displayed in several areas then should return the primary area that contains index and not the complete area that index might encompasses, touch or cause drawing.
在基类中,这是纯虚函数。
PySide2.QtWidgets.QAbstractItemView.
visualRegionForSelection
(
selection
)
¶
selection
–
QItemSelection
QRegion
返回来自项视口的区域在给定
selection
.
在基类中,这是纯虚函数。