I am trying to add a new column to a QSqlQueryModel and populate it with data not related to its database. There are 2 columns from the database query. I tried the following code to check if column insertion was successful.
if(atsFieldModel->insertColumn(2, testIndex.parent()))
QMessageBox::information(this, tr
("Successful"), tr
("column inserted!"));
QModelIndex testIndex = atsFieldModel->index(1, 1);
if(atsFieldModel->insertColumn(2, testIndex.parent()))
QMessageBox::information(this, tr("Successful"), tr("column inserted!"));
To copy to clipboard, switch view to plain text mode
But the messagebox does not appear. I also used insertColumns() method but it didn't work either. Please explain to me what I did wrong here. Thank you.
Bookmarks