Qt: Display data from QSqlQueryModel to TableView

Chilarai Mushahary
1 min readJul 12, 2020

This blog describes how you can display data directly from your Mysql table to a TableView in your application.

QSqlQueryModel lets you write your own query in the SQL which can be then used as a model in ListView, GridView, TableView, etc. This gives us a lot of convenience in handling the data in the view.

View Source Code in Github

mysqlmodel.h

mysqlmodel.cpp

main.cpp

main.qml

--

--