本页内容

QTableWidgetSelectionRange Class

QTableWidgetSelectionRange 类提供了一种在不使用模型索引和选择模型的情况下与模型中的选择进行交互的方法。更多内容...

头文件: #include <QTableWidgetSelectionRange>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets

公共函数

QTableWidgetSelectionRange()
QTableWidgetSelectionRange(int top, int left, int bottom, int right)
int bottomRow() const
int columnCount() const
int leftColumn() const
int rightColumn() const
int rowCount() const
int topRow() const
(since 6.3) bool operator!=(const QTableWidgetSelectionRange &lhs, const QTableWidgetSelectionRange &rhs)
(since 6.3) bool operator==(const QTableWidgetSelectionRange &lhs, const QTableWidgetSelectionRange &rhs)

详细说明

QTableWidgetSelectionRange 类用于存储表格中选定范围的左上角和右下角的行号与列号。表格中的选定内容可能由多个选定范围组成。

注意:如果 选择范围内的项目被标记为不可选,例如itemFlags() & Qt::ItemIsSelectable == 0 ,则该项目不会出现在选择范围内。

另请参阅 QTableWidget 。

成员函数文档

[constexpr noexcept default] QTableWidgetSelectionRange::QTableWidgetSelectionRange()

构建一个空的表选择范围,即其rowCount()和columnCount()均为0的范围。

另请参阅 topRow()、leftColumn()、bottomRow() 和rightColumn()。

QTableWidgetSelectionRange::QTableWidgetSelectionRange(int top, int left, int bottom, int right)

根据给定的top 、left 、bottom 和right 表的行和列,构建表的选取范围。

另请参阅 topRow()、leftColumn()、bottomRow() 和rightColumn() 函数。

int QTableWidgetSelectionRange::bottomRow() const

返回该范围的最后一行。

另请参阅 topRow()、rightColumn() 和rowCount()。

int QTableWidgetSelectionRange::columnCount() const

返回该范围中的列数。

这等同于 `rightColumn()` - `leftColumn()` + 1。

另请参阅 rowCount()、leftColumn()和rightColumn()。

int QTableWidgetSelectionRange::leftColumn() const

返回该范围的左侧列。

另请参阅 rightColumn()、topRow() 和columnCount()。

int QTableWidgetSelectionRange::rightColumn() const

返回该范围的右侧列。

另请参阅 leftColumn()、bottomRow() 和columnCount()。

int QTableWidgetSelectionRange::rowCount() const

返回该范围中的行数。

这等同于bottomRow() -topRow() + 1。

另请参见 columnCount()、topRow() 和bottomRow()。

int QTableWidgetSelectionRange::topRow() const

返回该范围的第一行。

另请参阅 bottomRow()、leftColumn() 和rowCount()。

相关的非成员函数

[noexcept, since 6.3] bool operator!=(const QTableWidgetSelectionRange &lhs, const QTableWidgetSelectionRange &rhs)

如果 `lhs ` 和 `rhs ` 不相等,则返回 true;否则返回 false。

该函数在 Qt 6.3 中引入。

[noexcept, since 6.3] bool operator==(const QTableWidgetSelectionRange &lhs, const QTableWidgetSelectionRange &rhs)

如果 `lhs ` 和 `rhs ` 相等,则返回 true;否则返回 false。

该函数在 Qt 6.3 中引入。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.