1
0
forked from IPKM/nmreval

subclass QTableWidget for change multiple checkstates

This commit is contained in:
Dominik Demuth 2023-07-29 18:47:15 +02:00
parent 7762e299e4
commit b6136bc8ce
2 changed files with 16 additions and 2 deletions

View File

@ -6,6 +6,7 @@ from ..Qt import QtCore, QtWidgets, QtGui
from .._py.fitmodelwidget import Ui_FitParameter
from .._py.save_fitmodel_dialog import Ui_SaveDialog
from ..lib.iconloading import get_icon
from ..lib.tables import TableWidget
class FitModelWidget(QtWidgets.QWidget, Ui_FitParameter):
@ -364,7 +365,7 @@ class FitModelTree(QtWidgets.QTreeWidget):
return funcs
class FitTableWidget(QtWidgets.QTableWidget):
class FitTableWidget(TableWidget):
def __init__(self, parent=None):
super().__init__(parent=parent)

View File

@ -29,3 +29,16 @@ class TreeWidget(QtWidgets.QTreeWidget):
it.setCheckState(0, QtCore.Qt.Unchecked if it.checkState(0) == QtCore.Qt.Checked else QtCore.Qt.Checked)
else:
super().keyPressEvent(evt)
class TableWidget(QtWidgets.QTableWidget):
def keyPressEvent(self, evt: QtGui.QKeyEvent):
if evt.key() == QtCore.Qt.Key.Key_Space:
for idx in self.selectedIndexes():
item = self.itemFromIndex(idx)
cs = item.checkState()
item.setCheckState(QtCore.Qt.CheckState.Unchecked if cs == QtCore.Qt.CheckState.Checked
else QtCore.Qt.CheckState.Checked)
else:
super().keyPressEvent(evt)