From 10:00 CET Friday 22nd November we will adjust how the server works to deal with some recently reported problems. Therefore there may be a load problem, if you experience more problems than usual trying to access the forum then please PM AndyS or any of the moderators so they can inform me.


How to show QSqlQuryModel in QML?



  • I want to show QSqlQuryModel in qml TableView but I don't Want 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



  • This post is deleted!

  • Lifetime Qt Champion

    Hi,

    Add a setter to your model that is Q_INVOKABLE and pass your query through it. Don't forget to add proper error checking to give feedback to your user if something goes wrong.