当QtableWidget失去焦点时,如何关闭选择
I'm making a GUI in PyQt5 which has a QTableWidget. Is there some way to get rid of the gray selection of the previous selected cell after moving focus from this QTableWidget to another widget in the GUI?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Palette 来控制不活动选择的颜色。将其设置为透明似乎是最好的解决方案,因为它也将与交替的行颜色一起使用:
如果您使用QT Designer,则可以通过属性编辑器编辑表的调色板。在“编辑调色板”对话框中,单击顶部的“显示详细信息”按钮,以显示无活动/残疾颜色的额外列。然后单击单元格以获得无效的高光颜色角色,然后将alpha通道设置为零。
You can use the palette to control the colour of the inactive selection. Setting it to transparent would seem the best solution, as it will also work with alternating row colours:
If you're using Qt Designer, you can edit the table's palette via the Property Editor. In the Edit Palette dialog, click the Show Details button at the top to display the extra columns for inactive/disabled colours. Then click on the cell for the Inactive Highlight colour role, and set the Alpha channel to zero.