Details
-
Bug
-
Resolution: Duplicate
-
P1: Critical
-
None
-
6.2.4
-
None
-
Python 3.10.5
OS: macOS 12.4
PySide: 6.2.4 (installed via pip)
Description
Checkbox placed in QTableView by setting Qt.ItemIsUserCheckable flag in the QAbstractTableModel subclass just doesn't check event the CheckStateRole data is successfully set to Qt.Checked.
my model, which worked perfectly with PySide 6.2.3:
class pandasModel(QtCore.QAbstractTableModel): def __init__(self, data:pd.DataFrame): super(pandasModel, self).__init__() self._data = data def rowCount(self, index): return self._data.shape[0] def columnCount(self, index): return self._data.shape[1] def data(self, index, role): row = index.row() column = index.column() value = self._data.iloc[row, column] if role == QtCore.Qt.DisplayRole: if value == True: return "Yes" elif value == False: return "No" else: return str(value) if role == QtCore.Qt.CheckStateRole and column == 2: if value == True: return QtCore.Qt.Checked else: return QtCore.Qt.Unchecked def setData(self, index, value, role): row = index.row() column = index.column() if role == QtCore.Qt.CheckStateRole and column == 2: if value == QtCore.Qt.Checked: self._data.iloc[row, column] = True self.dataChanged.emit(index, index) elif value == QtCore.Qt.Unchecked: self._data.iloc[row, column] = False self.dataChanged.emit(index, index) return True return False def flags(self, index): flags = super().flags(index) if index.column() == 2: flags |= QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsUserCheckable return flags def headerData(self, section, orientation, role): # section is the index of the column/row. if role == QtCore.Qt.DisplayRole: if orientation == QtCore.Qt.Horizontal: return str(self._data.columns[section]) elif orientation == QtCore.Qt.Vertical: return str(self._data.index[section])
This issue occured after I upgrade PySide6 from 6.2.3 to 6.2.4, while my code worked perfectly with 6.2.3.
Attachments
Issue Links
- duplicates
-
PYSIDE-1930 REG ->6.2.4: Cannot return Qt.CheckState enum values from QAbstractItemModel::flags()
- Closed