有没有办法我可以在 qtablewidget 中隐藏所选单元格的边框(或使边框颜色为白色)。默认情况下,会显示带虚线的边框。你能帮帮我吗...
最佳答案
Qt::NoFocus
将删除 QTableWidget
中行的选定状态.Python3/PySide2
接受答案的版本:
class NoFocusDelegate(QtWidgets.QStyledItemDelegate):
def paint(self, painter: PySide2.QtGui.QPainter, option: PySide2.QtWidgets.QStyleOptionViewItem, index: PySide2.QtCore.QModelIndex) -> None:
itemOption = QtWidgets.QStyleOptionViewItem(option)
if option.state & QtWidgets.QStyle.State_HasFocus:
itemOption.state = itemOption.state ^ QtWidgets.QStyle.State_HasFocus
super().paint(painter, itemOption, index)
table.setItemDelegate(NoFocusDelegate())
非常适合我。
关于pyqt - 在pyqt中隐藏qtablewidget中选定单元格的边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2055705/