QTableView - 当用户通过单击选择一行时发送什么信号?

发布于 2024-08-18 12:40:07 字数 48 浏览 6 评论 0原文

当用户通过鼠标在 QTableView 中选择一行(单选模型)时,是否会发出信号?

Is there a signal which is emitted when the user selects a row in QTableView by mouse (single selection model)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦中楼上月下 2024-08-25 12:40:07

每个视图都有一个选择模型:

QItemSelectionModel * QAbstractItemView::selectionModel () const

通过选择模型,您可以检索大量信息,在您的情况下:

QModelIndexList QItemSelectionModel::selectedRows ( int column = 0 ) const

所以:

myTableView->selectionModel()->selectedRows();

然后您可以通过如下信号检索这些信息:

void QItemSelectionModel::selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected )   [signal]

希望它有帮助!

Each view has a Selection model :

QItemSelectionModel * QAbstractItemView::selectionModel () const

and with the selection model you can retrieve lots of informations, in your case :

QModelIndexList QItemSelectionModel::selectedRows ( int column = 0 ) const

So :

myTableView->selectionModel()->selectedRows();

You can then retrieve this informations through a signal like :

void QItemSelectionModel::selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected )   [signal]

Hope it helps !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文