Hi everyone,
I am currently trying to make simple program to connect to a sql database, since I want to have several tables with relationships I decided to try and subclass QSqlTableModel, but I encountered some problems. What I want to do is use the original removeRows to clear the Main table I work on and then add a little bit of code to remove the related data from the other tables; but for some reason when I try to do removeRows I always get false. I also tried calling directly the original method without subclassing it but I still get false.
Here is the code I use to call removeRows:
Qt Code:
  1. int row = dbTableView->currentIndex().row();
  2. dbmodel->removeRows(row,1);
To copy to clipboard, switch view to plain text mode 

On the other hand if I subclass removeRows and basically copy the method from the original code I am able to delete the record without problems. So basically if I use this code:
Qt Code:
  1. bool MySqlTableModel::removeRows(int row,int count, const QModelIndex &parent){
  2.  
  3. if (parent.isValid() || row < 0 || count <= 0)
  4. return false;
  5.  
  6. int i;
  7. switch (editStrategy()) {
  8. case OnFieldChange:
  9. case OnRowChange:
  10. for (i = 0; i < count; ++i) {
  11. if (row + i == insertIndex)
  12. qDebug()<<"Should revert row";
  13. else if (!QSqlTableModel::deleteRowFromTable(row + i))
  14. return false;
  15. }
  16. select();
  17. break;
  18. case OnManualSubmit:
  19. for (i = 0; i < count; ++i) {
  20. int idx = row + i;
  21. if (idx >= rowCount())
  22. return false;
  23.  
  24. }
  25. break;
  26. }
  27. return true;
To copy to clipboard, switch view to plain text mode 

Also if I just call deleteRowFromTable I am successful and it returns true.
What could be returning me false when I call the original method through QSqlTableModel::removeRows()?
I am using Qt 5.2.1 on a Mac OSX Mavericks.
Thank you very much