当QtableWidget失去焦点时,如何关闭选择

发布于 2025-02-13 02:24:23 字数 259 浏览 1 评论 0原文

我正在使用具有QTableWidget的PYQT5进行GUI。是否有某种方法可以在将焦点从此QTableWidget移动到GUI中的另一个小部件后,摆脱以前选定的单元的灰色选择?

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?

Part of my GUI

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

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

发布评论

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

评论(1

悲歌长辞 2025-02-20 02:24:23

您可以使用 Palette 来控制不活动选择的颜色。将其设置为透明似乎是最好的解决方案,因为它也将与交替的行颜色一起使用:

palette = self.table.palette()
palette.setColor(QPalette.Inactive, QPalette.Highlight, Qt.transparent)
self.table.setPalette(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:

palette = self.table.palette()
palette.setColor(QPalette.Inactive, QPalette.Highlight, Qt.transparent)
self.table.setPalette(palette)

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.

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