如何的到QTableWidgetItem的位置?

如何得到QTableWidgetItem的位置?

如何得到QTableWidgetItem的位置?

how to get the position of QTableWidgetItem in table

这里有个方案,使用mapto

https://forum.qt.io/topic/114636/how-to-get-the-position-of-widgets-in-qtablewidget/5

https://stackoverflow.com/questions/32218392/get-cell-position-of-qcheckbox-in-qtablewidget

这些方案都有一个统一的思路就是,提前把结果存在字典里;

QMap

可以自己设计一套规则

1、构建一个字典,key是你定义的比如treewidget的cell的pos(x-y);value是TableWidgetItem;

2、使将问题转换成,如何根据字典value找到它对应的key?

3、如下

def getTWIKey(self,twi):
    if twi in self.qmap.values():
	    ans = list(self.qmap.keys())[list(self.qmap.values()).index(twi)]
    return ans
posted @   bH1pJ  阅读(48)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示