Exemplo n.º 1
0
 def excel_like_enter_filter(source: QtWidgets.QTableView,
                             event: QtCore.QEvent):
     if event.type() == event.KeyPress:
         if event.key() in [QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter]:
             if int(source.editTriggers()) > int(
                     QtWidgets.QAbstractItemView.NoEditTriggers):
                 next_row = source.currentIndex().row() + 1
                 if next_row + 1 > source.model().rowCount():
                     next_row -= 1
                 if source.state() == source.EditingState:
                     next_index = source.model().index(
                         next_row,
                         source.currentIndex().column())
                     source.setCurrentIndex(next_index)
                 else:
                     source.edit(source.currentIndex())