QItemSelectionRange 類

QItemSelectionRange 類管理模型選中項範圍的有關信息。 更多...

頭: #include <QItemSelectionRange>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

此類 相等可比較 .

公共函數

QItemSelectionRange ()
QItemSelectionRange (const QModelIndex & index )
QItemSelectionRange (const QModelIndex & topLeft , const QModelIndex & bottomRight )
int bottom () const
const QPersistentModelIndex & bottomRight () const
bool contains (const QModelIndex & index ) const
bool contains (int row , int column , const QModelIndex & parentIndex ) const
int height () const
QModelIndexList indexes () const
QItemSelectionRange intersected (const QItemSelectionRange & other ) const
bool intersects (const QItemSelectionRange & other ) const
bool isEmpty () const
bool isValid () const
int left () const
const QAbstractItemModel * model () const
QModelIndex parent () const
int right () const
void swap (QItemSelectionRange & other )
int top () const
const QPersistentModelIndex & topLeft () const
int width () const
bool operator!= (const QItemSelectionRange & lhs , const QItemSelectionRange & rhs )
bool operator== (const QItemSelectionRange & lhs , const QItemSelectionRange & rhs )

詳細描述

A QItemSelectionRange contains information about a range of selected items in a model. A range of items is a contiguous array of model items, extending to cover a number of adjacent rows and columns with a common parent item; this can be visualized as a two-dimensional block of cells in a table. A selection range has a top (), left () bottom (), right () 和 parent ().

The QItemSelectionRange class is one of the 模型/視圖類 且屬於 Qt 的 模型/視圖框架 .

The model items contained in the selection range can be obtained using the indexes () function. Use QItemSelectionModel::selectedIndexes () to get a list of all selected items for a view.

You can determine whether a given model item lies within a particular range by using the contains () function. Ranges can also be compared using the overloaded operators for equality and inequality, and the intersects () function allows you to determine whether two ranges overlap.

另請參閱 模型/視圖編程 , QAbstractItemModel , QItemSelection ,和 QItemSelectionModel .

成員函數文檔編製

[noexcept] QItemSelectionRange:: QItemSelectionRange ()

Constructs an empty selection range.

[explicit] QItemSelectionRange:: QItemSelectionRange (const QModelIndex & index )

Constructs a new selection range containing only the model item specified by the model index index .

QItemSelectionRange:: QItemSelectionRange (const QModelIndex & topLeft , const QModelIndex & bottomRight )

Constructs a new selection range containing only the index specified by the topLeft and the index bottomRight .

int QItemSelectionRange:: bottom () const

Returns the row index corresponding to the lowermost selected row in the selection range.

const QPersistentModelIndex &QItemSelectionRange:: bottomRight () const

Returns the index for the item located at the bottom-right corner of the selection range.

另請參閱 bottom (), right (),和 topLeft ().

bool QItemSelectionRange:: contains (const QModelIndex & index ) const

返迴 true if the model item specified by the index lies within the range of selected items; otherwise returns false .

bool QItemSelectionRange:: contains ( int row , int column , const QModelIndex & parentIndex ) const

返迴 true if the model item specified by ( row , column ) and with parentIndex as the parent item lies within the range of selected items; otherwise returns false .

這是重載函數。

int QItemSelectionRange:: height () const

Returns the number of selected rows in the selection range.

QModelIndexList QItemSelectionRange:: indexes () const

Returns the list of model index items stored in the selection.

QItemSelectionRange QItemSelectionRange:: intersected (const QItemSelectionRange & other ) const

Returns a new selection range containing only the items that are found in both the selection range and the other selection range.

bool QItemSelectionRange:: intersects (const QItemSelectionRange & other ) const

返迴 true if this selection range intersects (overlaps with) the other range given; otherwise returns false .

bool QItemSelectionRange:: isEmpty () const

返迴 true if the selection range contains either no items or only items which are either disabled or marked as not selectable.

bool QItemSelectionRange:: isValid () const

返迴 true if the selection range is valid; otherwise returns false .

int QItemSelectionRange:: left () const

Returns the column index corresponding to the leftmost selected column in the selection range.

const QAbstractItemModel *QItemSelectionRange:: model () const

Returns the model that the items in the selection range belong to.

QModelIndex QItemSelectionRange:: parent () const

Returns the parent model item index of the items in the selection range.

Returns the column index corresponding to the rightmost selected column in the selection range.

[noexcept] void QItemSelectionRange:: swap ( QItemSelectionRange & other )

Swaps this selection range's contents with other 。此操作很快且從不失敗。

int QItemSelectionRange:: top () const

Returns the row index corresponding to the uppermost selected row in the selection range.

const QPersistentModelIndex &QItemSelectionRange:: topLeft () const

Returns the index for the item located at the top-left corner of the selection range.

另請參閱 top (), left (),和 bottomRight ().

int QItemSelectionRange:: width () const

Returns the number of selected columns in the selection range.

相關非成員

[noexcept] bool operator!= (const QItemSelectionRange & lhs , const QItemSelectionRange & rhs )

返迴 true if lhs selection range differs from the rhs range given; otherwise returns false .

[noexcept] bool operator== (const QItemSelectionRange & lhs , const QItemSelectionRange & rhs )

返迴 true if lhs selection range is exactly the same as the rhs range given; otherwise returns false .