1.获得选中行的QModelIndex
connect(tableview->selectionModel(), QItemSelectionModel::currentRowChanged, this, [=](const QModelIndex ¤t,const QModelIndex &previous){
emit Siganl(current);
}
2.根据QModelIndex获得所在单元格的位置
connect(this, & ::Signal, this, [=](QModelIndex cur){
QRect rect = tableview->visualRect(index);
qDebug()<<rect.x()<<rect.y();
}
)
QTableView如何获得选中单元格的相对位置?
最新推荐文章于 2024-08-28 14:36:19 发布
文章介绍了如何在Qt中通过QModelIndex获取选中的行号并监听其变化,以及如何根据模型索引获取单元格的实际位置的技术。
4959

被折叠的 条评论
为什么被折叠?



