I want to show QSqlQueryModel in qml TableView but I don't Wan't to create separate QML file for each new query cause I can't create infinite qml files as given here . Also question is not working for me for dynamic number of columns (could be version difference as I am using 5.11) .I just want something like:-
QTableView *view = new QTableView;
view->setModel(model);
view->show();
in QML.
I am new to qml. So far I am able show QSqlQueryModel as guided in first link but my user may enter any SQL Query.
Using information from A more generic approach of How to Use a QSqlQueryModel in QML you can build a general model, to make it easy to use from QML you can create a property to pass the query.
sqlquerymodel.h
main.cpp
main.qml