Hello,

I have a problem with a QTableView where the cells change randomly when I modify one of them. To isolate it, I have made an extremely simple window where the problem still occurs.

This window contains just a QTableView related to a model. If I modify a value, there is often another value of the same columns that is modified as well more or less randomly.

Here is the code.

Qt Code:
  1. #ifndef TESTWINDOW2
  2. #define TESTWINDOW2
  3.  
  4. #include <QtGui>
  5. #include <QWidget>
  6. #include <QGridLayout>
  7. #include <QTableView>
  8. #include <QSqlTableModel>
  9.  
  10. class TestWindow2 : public QWidget{
  11. Q_OBJECT
  12. public:
  13. TestWindow2();
  14. QTableView *tableView;
  15. QGridLayout *layout;
  16. };
  17.  
  18. #endif
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include "testwindow2.h"
  2.  
  3. TestWindow2::TestWindow2() : QWidget(0){
  4. model=new QSqlTableModel();
  5. model->setTable("testtable");
  6. model->select();
  7. tableView=new QTableView();
  8. tableView->setModel(model);
  9. layout=new QGridLayout();
  10. layout->addWidget(tableView);
  11. setLayout(layout);
  12. }
To copy to clipboard, switch view to plain text mode 

What can I do?

Thanks!