Tweaking Qt sql-model code got desired results -

Qt Code:
  1. diff -r ../../../QtSDK-orig/QtSources/4.8.1/src/sql/models/qsqlrelationaltablemodel.cpp ./src/sql/models/qsqlrelationaltablemodel.cpp
  2. 241a242
  3. > setFilter(relation->rel.where()); // This seems to work...
  4. diff -r ../../../QtSDK-orig/QtSources/4.8.1/src/sql/models/qsqlrelationaltablemodel.h ./src/sql/models/qsqlrelationaltablemodel.h
  5. 58,59c58,59
  6. < const QString &displayCol)
  7. < : tName(aTableName), iColumn(indexCol), dColumn(displayCol) {}
  8. ---
  9. > const QString &displayCol, const QString &where = QString())
  10. > : tName(aTableName), iColumn(indexCol), dColumn(displayCol), _where(where) {}
  11. 65a66,67
  12. > inline QString where() const
  13. > { return _where; }
  14. 69c71
  15. < QString tName, iColumn, dColumn;
  16. ---
  17. > QString tName, iColumn, dColumn, _where;
To copy to clipboard, switch view to plain text mode 

This allows specifying your WHERE clause to limit the association options for model relations - no special delegate is required.

Qt Code:
  1. Game::m_tmodel->setRelation(4, QSqlRelation("team", "id", "name", "team.division_id IN (1,10,11,12)" ));
To copy to clipboard, switch view to plain text mode