Hi everyone. Im having the following problem. I can fetch all the rows of my query and view this model with the QTableView.

But the problem comes when, after updating a cell, the view of the model trims again only showing the first 256 rows. Here is the class:

Qt Code:
  1. WidgetModificacion::WidgetModificacion(QWidget *parent, int tipo_tabla) :
  2. QWidget(parent),
  3. ui(new Ui::WidgetModificacion)
  4. {
  5. ui->setupUi(this);
  6. this->tipo_tabla = tipo_tabla;
  7. db = QSqlDatabase::database ("app_db");
  8. if (db.isOpen ()){
  9. model = new QSqlTableModel (this, db);
  10. switch (tipo_tabla){
  11. case 0:
  12. model->setTable ("TABLE_PRODUCTOS");
  13. break;
  14. case 1:
  15. model->setTable ("TABLE_CLIENTES");
  16. break;
  17. }
  18. model->setEditStrategy(QSqlTableModel::OnFieldChange);
  19. model->setSort (1, Qt::AscendingOrder);
  20. model->select ();
  21. while (model->canFetchMore()) model->fetchMore();
  22. this->ui->tableView->setModel (model);
  23. QStyledItemDelegate *display = new NumberRepresentation(this);
  24. ui->tableView->setItemDelegateForColumn (0, display);
  25. ui->tableView->setItemDelegateForColumn (4, display);
  26. ui->tableView->setColumnWidth(1,250);
  27. connect (this->model, SIGNAL(beforeUpdate (int, QSqlRecord &)), this, SLOT (actualizar_fecha (int, QSqlRecord &)));
  28. }
  29. else{
  30. QMessageBox::critical(0, qApp->tr("Cannot open database"),
  31. qApp->tr("Unable to establish a database connection.\n"
  32. "Llamar a Agus.\n\n"
  33. "Click Cancel to exit."), QMessageBox::Cancel);
  34. }
  35. }
  36.  
  37. WidgetModificacion::~WidgetModificacion()
  38. {
  39. delete ui;
  40. }
  41.  
  42. void WidgetModificacion::on_cerrar_clicked()
  43. {
  44. emit finaliza_modificacion (QString (":ImagesMilk/Iconos/uvacopa.png"));
  45. this->db.close ();
  46. this->close ();
  47. }
  48.  
  49. void WidgetModificacion::actualizar_fecha (int row, QSqlRecord & record){
  50. if (tipo_tabla == 0){
  51. QSqlQuery *query = new QSqlQuery (db);
  52. query->prepare ("UPDATE TABLE_PRODUCTOS SET fecha_modificacion = SYSDATE WHERE id_codigo_barra = :value");
  53. query->bindValue (":value", this->ui->tableView->model ()->data (this->ui->tableView->model ()->index (row, 0)).toString ());
  54. query->exec ();
  55. //while (model->canFetchMore()) model->fetchMore();
  56. //this->ui->tableView->setModel (model);
  57. }
  58. }
To copy to clipboard, switch view to plain text mode 

The code that is commented i've alredy tried it, and doesnt work. What i want is to modify the cell and stay at the same position of the table i was before the update. Thank you all in advance.