1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| void customTableView::searchNextIndex() {
int row = currentIndex().row();
int col = currentIndex().column();
// Following cell
row++;
if(row>=model()->rowCount()) {
row = 0;
col++;
}
if(col>=model()->columnCount()) {
col = 0;
}
// Loop while following cell is not selectable (or a complete loop has been done)
unsigned int counter = 0;
unsigned int maxCounter = model()->rowCount()*model()->columnCount()-1;
Qt::ItemFlags currentFlag = model()->flags(model()->index(row, col));
while(counter<maxCounter && !currentFlag.testFlag(Qt::ItemIsSelectable)) {
row++;
if(row>=model()->rowCount()) {
row = 0;
col++;
}
if(col>=model()->columnCount()) {
col = 0;
}
currentFlag = model()->flags(model()->index(row, col));
counter++;
}
setCurrentIndex(model()->index(row, col));
scrollTo(model()->index(row, col));
} |
Partager