Sort by column header in tablemodel
I've checked the forums and documentation but still can't seem to get it to work. Supposed to be essentially "automatic" and "built-in" using one line of code but the sort function just doesn't happen. The arrow indicators do show up but that's all that happens.
Thank you for your help.
Here's the code:
QT += core gui sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = SQLIte_Login
TEMPLATE = app
SOURCES += main.cpp
HEADERS += login.h
FORMS += login.ui
RC_FILE = nhx.rc@
int main(int argc, char *argv)
QApplication a(argc, argv);
QSqlQueryModel * modal=new QSqlQueryModel();
QSqlQuery* qry=new QSqlQuery(conn.mydb);
qry->prepare("SELECT LotNo, UserName, LastName, Role from Test_LOGIN order by LotNo ");
I can not understand what is your problem is. If you can clarify more, I by myself or someone can try to help you.
Thanks for the reply.
I can load data from a SQLite table in a TableView on a gui form. The problem is that you are supposed to be able to re-sort the table by clicking on the column headers. To toggle from ascending to descending.
The sort direction triangles (up/down arrows) show up in the header but clicking on it does not re-sort the table.