Hi Everyone,

What I am doing is, I am creating 2 tables,
userFp(Primary table), user(Foreign key table)
. Then I am trying to display the resulting RELATION in a tableview. But I am not able to detect what's going wrong with my code. Following is my code:

Qt Code:
  1. QSqlQuery query(db); //db is the QSqlDatabase created on QSqlite
  2. ret = query.exec("PRAGMA foreign_keys = ON;");
  3.  
  4. ret = query.exec("create table userFp(FpID INTEGER PRIMARY KEY, FpCount INTEGER)");
  5.  
  6. ret=query.exec("create table user(UserID INTEGER PRIMARY KEY,Name varchar(50),"
  7. "FpID INTEGER, FOREIGN KEY(FpID) REFERENCES userFp(FpID) ON UPDATE CASCADE)");
  8.  
  9. .....
  10. .....
  11. ..... inserting the values into the 2 tables
  12. .....
  13. .....
  14.  
  15. model->setTable("user");
  16. model->setRelation(2,QSqlRelation("userFp","FpID","FpCount")); //NOTE- Here I am not sure whether to give column index as 3 or 2. I tried with both.
  17.  
  18. ui->tableView->setModel(model);
  19. ui->tableView->setItemDelegate(new QSqlRelationalDelegate(ui->tableView));
To copy to clipboard, switch view to plain text mode 


The Problem is I am not getting any error upon execution, but my ui->tableview remains blank. Can anyone point out where I am going wrong or rather what I am missing?


With regards,
sattu