for( int row = 0; row < model->rowCount() - 1; ++row ){ QModelIndex topLevelIndex = model->index( row, 0 ); ...}