Unsolved Changing field order in QSqlTableModel
-
Hi,
I have a QSqlTableModel which displays the fields of a db in a tableWiew. I want to display the fields in a different order in the tableView than the fields are listed in the db table. How can I do that?Currently I have the following to display the data:
QSqlDatabase db = QSqlDatabase::addDatabase ("QSQLITE"); db.setDatabaseName ("C:/Programming/Projects/Folkfriends_bzr/trunk/db.db"); if(!db.open ()) QMessageBox::information (this, "Error", "Couldn't open database."); QSqlTableModel* fixModel = new QSqlTableModel(this); fixModel->setTable ("Items"); fixModel->setEditStrategy (QSqlTableModel::OnFieldChange); fixModel->setSort (1, Qt::DescendingOrder); fixModel->select (); ui->tableView_Fix->setModel (fixModel);
Thank you for your help.
-
Did u get a chance to look at this old post ?
https://forum.qt.io/topic/10842/specify-column-ordering-in-qsqltablemodel-was-problem-moving-columns-of-a-qtableview/1 -
-
@dheerendra
Yes, but it moves the column header not the actual column. I want to display the columns in a diferent order than they are in the db.