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();
};
#endif
#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
To copy to clipboard, switch view to plain text mode
#include "testwindow2.h"
TestWindow2
::TestWindow2() : QWidget(0){ model->setTable("testtable");
model->select();
tableView->setModel(model);
layout->addWidget(tableView);
setLayout(layout);
}
#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);
}
To copy to clipboard, switch view to plain text mode
What can I do?
Thanks!
Bookmarks