You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Sunday, June 26th 2011, 1:04pm

Cannot see the header labels SQL

Dear Friends

I am trying to generate a table with the code below. But I cannot see the header labels in the view. Only a blank page is coming. Please give me some suggestion. Thanks sujan
QSqlQueryModel *model = new QSqlQueryModel;
model->setTable("student");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->select();
model->setHeaderData(0, Qt::Horizontal, tr("studentID"));
model->setHeaderData(1, Qt::Horizontal, tr("Name"));
model->setHeaderData(2, Qt::Horizontal, tr("FirstName"));
model->database().transaction();
qDebug() << model->database().commit();
model->submitAll();
QTableView *view = new QTableView;
view->setModel(model);
view->show()

2

Monday, August 8th 2011, 5:52pm

Is it compiling? very strange.

the setTable method works only in QSqlTableModel.
sobstitute this

Source code

1
QSqlQueryModel *model = new QSqlQueryModel;

with this

Source code

1
QSqlTableModel *model = new QSqlTableModel();