从QTableVi提取最后一列数据

2024-10-03 17:19:22 发布

您现在位置:Python中文网/ 问答频道 /正文

根据this question的答案,我找到了访问QTableView中所选行的第一列的方法。但是如何访问最后一列,而不硬编码列号?你知道吗

        itmIndex = self.viewInQuestion.currentIndex()
        id = itmIndex.sibling(itmIndex.row(), -1)

不起作用。有什么建议吗?你知道吗


Tags: 方法答案selfid编码this建议row
1条回答
网友
1楼 · 发布于 2024-10-03 17:19:22

以下方法有效:

        itmIndex = self.viewInQuestion.currentIndex()
        id = itmIndex.sibling(itmIndex.row(), self.modelForView.columnCount() - 1)
        itmCt = self.modelForView.data(id).toFloat()

相关问题 更多 >