PDA

View Full Version : Strange problem with a QTableView



pippo42
3rd May 2010, 14:46
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.



#ifndef TESTWINDOW2
#define TESTWINDOW2

#include <QtGui>
#include <QWidget>
#include <QGridLayout>
#include <QTableView>
#include <QSqlTableModel>

class TestWindow2 : public QWidget{
Q_OBJECT
public:
TestWindow2();
QTableView *tableView;
QGridLayout *layout;
QSqlTableModel *model;
};

#endif




#include "testwindow2.h"

TestWindow2::TestWindow2() : QWidget(0){
model=new QSqlTableModel();
model->setTable("testtable");
model->select();
tableView=new QTableView();
tableView->setModel(model);
layout=new QGridLayout();
layout->addWidget(tableView);
setLayout(layout);
}


What can I do?

Thanks!