So I have a list of QTableWidgetItems
via pyqt
and I want to check if the rows of these elements are all in succession of each other, otherwise I would need to error-handle. I tried:
for i in list(selectedItems):
if ((i+1).row - i.row) != 1:
print("Selected Items are not succeeding each other")
And I tried to use itertools.cycle
with no avail. Any leads?
Edit: Ok, so here is a bit more info. My first proposed solution will get me the error Message:
TypeError: unsupported operand type(s) for +: 'QTableWidgetItem' and 'int'
And when using a cycle I could no find a possibility to reach the 'QTableWidgetItem.row()' method. What I want is a simple function that will check if the difference in rows stays at 1 for all the elements I have currently selected, otherwise it means there are items selected which have a "gap" between them which my code currently cannot handle. When that case happens I will simply disable the grouping function until the selection falls within my criteria again.