QTableWidget 如何从代码和/或单击中选择一个单元格进行编辑
两个部分问题: 我有一个10x10 QTableWidget,每个单元格中都有QTableWidgetItem。 由于某种原因,单击单元格不足以编辑它,我需要双击单元格以输入它。
是否有一种方法可以将此行为更改为单击
有没有办法在第1行中选择第二个单元格,默认情况下可以编辑当创建窗口时?
Two part question:
I have a 10x10 QTableWidget with QTableWidgetItem in each cell.
For some reason, clicking on a cell is not sufficient to edit it, I need to double-click the cell to enter it.
Is there a way to change this behavior to single click
Is there a way to have 2nd cell in 1st row selected and ready for editing by default when window is created?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 setEditTriggers 以各种方式修改编辑行为。
对于单击,请尝试:
可以使用 editItem:
要选择单元格而不对其进行编辑,请使用 设置当前单元格:
You can modify the editing behaviour in various ways with setEditTriggers.
For single-click, try:
The current edited cell can be set with editItem:
To select a cell without editing it, use setCurrentCell:
您还可以使用 setCurrentCell。
table.setCurrentCell(0,1)
QTableWidget.setCurrentCell(自身,int行,int列)
You can also use setCurrentCell.
table.setCurrentCell(0,1)
QTableWidget.setCurrentCell (self, int row, int column)