【问题标题】:QTableView - what signal is sent when user selects a row by clicking to it?QTableView - 当用户通过单击选择一行时发送什么信号?
【发布时间】:2011-01-04 23:52:22
【问题描述】:

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

【问题讨论】:

  • 绝对是鼠标?

标签: qt qtableview


【解决方案1】:

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

QItemSelectionModel * QAbstractItemView::selectionModel () const

使用选择模型,您可以检索大量信息:

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

所以:

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

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

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

希望对你有帮助!

【讨论】:

  • 检测点击表格视图元素的另一种方法是使用“void QAbstractItemView::clicked (const QModelIndex & index)”信号
猜你喜欢
  • 1970-01-01
  • 2020-10-02
  • 2018-05-30
  • 1970-01-01
  • 1970-01-01
  • 2013-11-14
  • 2021-02-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多