def moveCursor(self, cursorAction, modifiers): current = QTableView.moveCursor(self, cursorAction, modifiers) x = self.visualRect(current).topLeft().x() frozen_width = self.frozenTableView.columnWidth( 0) + self.frozenTableView.columnWidth(1) if cursorAction == self.MoveLeft and current.column( ) > 1 and x < frozen_width: new_value = self.horizontalScrollBar().value() + x - frozen_width self.horizontalScrollBar().setValue(new_value) return current
def moveCursor(self, cursor_action, modifiers): """Update the table position. Updates the position along with the frozen column when the cursor (selector) changes its position """ current = QTableView.moveCursor(self, cursor_action, modifiers) col_width = (self.frozen_table_view.columnWidth(0) + self.frozen_table_view.columnWidth(1)) topleft_x = self.visualRect(current).topLeft().x() overflow = self.MoveLeft and current.column() > 1 overflow = overflow and topleft_x < col_width if cursor_action == overflow: new_value = (self.horizontalScrollBar().value() + topleft_x - col_width) self.horizontalScrollBar().setValue(new_value) return current