QTableView 带有所有字段的编辑器
我正在尝试修改 QTableView 以始终显示所有编辑器。我同意在所有单元格上调用 openPersistentEditor()
的解决方法。
但是,我希望不选择单元格的内容,并且空字段没有文本光标。
这就是我得到的:
这就是我想要的:
我尝试使用 clearSelection()
和 clearFocus()
但这确实不做这个伎俩。如果我单击每个单元格,我会得到所需的结果,并且我可以以编程方式执行相同的操作,但我想知道是否有更直接的方法。
I am trying to modify the QTableView
to always show all editors. I am ok with the workaround to call openPersistentEditor()
on all cells.
However I'd like the content of the cells to not be selected and no text cursor for empty fields.
This is what I get:
And this is what I'd like to have:
I tried using clearSelection()
and clearFocus()
but that does not do the trick. If I click on each cell I get the desired result and I could do the same thing programmatically, but I'd to know if there's a more direct way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有这个完全相同的问题。我最终只是调整了 QLineEdits 上的选择颜色和选择背景颜色。您可以在所有 QLineEdit 上执行此操作,也可以仅在自定义 QLineEdit 上执行此操作,方法是为每个编辑器指定一个对象名称并在样式表中引用该名称。
I had this exact same issue. I ended up just adjusting the selection color and selection background color on the QLineEdits. You can do it on all QLineEdits or just on a custom QLineEdit by giving each editor an object name and referencing that in the stylesheet.