Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

QSqlTableModel sorting by multiple columns

$
0
0
Hey I have a table in MS SQL I am retrieving with a QSqlTableModel. I need the records to be sorted on a datetime field and also on an int field that I display as a check box, so just 1’s and 0’s, and if its checked I need all those values to be at the bottom of the list. I wrote the program on my laptop using a database with all the same fields and everything as the actual database that it will be using and used tableModel->setSort(DateTime, Qt::AscendingOrder);     tableModel->select();     tableModel->setSort(checkField, Qt::AscendingOrder);     tableModel->select(); And that was working fine on my computer. Then when I moved it to the network to test it on the actual database it is only sorting by the checkField and in no order at all by the datetime field. I was going to try writing a query but then realized that the setQuery() function for QSqlTableModel is protected so I can’t do that. Does anyone know any way for me to be able to do this? Thank you

Viewing all articles
Browse latest Browse all 18427

Trending Articles