通过在Python中拥有行号和列号,在单元格表小部件中找到一个值

发布于 2025-02-02 02:39:49 字数 751 浏览 3 评论 0原文

我在Python中有一个QT表小部件,在其中找到了行号,最后一项的列号以这种方式更改:

class elencoviaggi(QtWidgets.QDialog):
 def __init__(self):
    super(elencoviaggi, self).__init__()
    uic.loadUi('elenco_viaggi.ui', self)
    self.tabella_registrazioni.setColumnWidth(0, 30)
    self.tabella_registrazioni.setColumnWidth(1, 100)
    self.botton = self.findChild(QtWidgets.QPushButton, 'pushButton_3') 
    self.botton.clicked.connect(self.salva) !

 def salva(self): 
    print(self.tabella_registrazioni.itemChanged.connect(self.changeIcon))   
 def changeIcon(self, item):
    row = item.row()
    col = item.column()

在代码的这一部分中,我通过按钮正确找到行编号和列号的列号用户更改了最后一项,我如何存储在具有0列0的项目中,并以“行”变量为行?我尝试了此tabella_registrazioni.item(行,0),但不起作用。 我不知道使用行和列号找到项目的命令是什么

I have a QT Table Widget in python where I find the row number and the column number of the last item changed by the user in this way :

class elencoviaggi(QtWidgets.QDialog):
 def __init__(self):
    super(elencoviaggi, self).__init__()
    uic.loadUi('elenco_viaggi.ui', self)
    self.tabella_registrazioni.setColumnWidth(0, 30)
    self.tabella_registrazioni.setColumnWidth(1, 100)
    self.botton = self.findChild(QtWidgets.QPushButton, 'pushButton_3') 
    self.botton.clicked.connect(self.salva) !

 def salva(self): 
    print(self.tabella_registrazioni.itemChanged.connect(self.changeIcon))   
 def changeIcon(self, item):
    row = item.row()
    col = item.column()

In this part of the code I correctly find through a button the row number and the column number of the last item changed by the user, how can I store in a variable the item that has column 0 and as row the "row" variable declared? I tried this tabella_registrazioni.Item(row, 0) but doesn't work.
I don't know what is the command to find an item using row and column numbers

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

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

发布评论

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

评论(1

So尛奶瓶 2025-02-09 02:39:49

如果某人有同样的问题,则命令是:

self.yourtablename.item(therownumber, thecolumnnumber)

If someone has the same issue the command is :

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