SQLite integration with Qt Widgets
-
wrote on 18 Nov 2021, 09:54 last edited by
Hi All,
Hope you're doing well.
I want to integrate SQLite in one of my Qt projects where the result of SQLite should appear as the central widget of the main window. Is it possible to do so, if yes, how? I just don't simply want to display the solution of my query in Qt Creator's console but I want the output of the SQLite interface should occupy the central Widget of the MainWindow.
Any help will be highly appreciated!
Thanks.
-
Hi All,
Hope you're doing well.
I want to integrate SQLite in one of my Qt projects where the result of SQLite should appear as the central widget of the main window. Is it possible to do so, if yes, how? I just don't simply want to display the solution of my query in Qt Creator's console but I want the output of the SQLite interface should occupy the central Widget of the MainWindow.
Any help will be highly appreciated!
Thanks.
wrote on 18 Nov 2021, 09:59 last edited by@Swati777999
If you want no more than what console output would show (i.e. some text for the rows & columns) but visible in a widget, just create, say, aQPlainTextEdit
(or even just aQLabel
) as the central widget and put the textual representation of the result set returned from the query there.If you want something a bit "nicer", say a table with rows & columns from the query, then create a
QTableView
as the central widget and bind it to the SQLite model you are using. -
Hi All,
Hope you're doing well.
I want to integrate SQLite in one of my Qt projects where the result of SQLite should appear as the central widget of the main window. Is it possible to do so, if yes, how? I just don't simply want to display the solution of my query in Qt Creator's console but I want the output of the SQLite interface should occupy the central Widget of the MainWindow.
Any help will be highly appreciated!
Thanks.
wrote on 18 Nov 2021, 10:44 last edited byTo extend @JonB answer:
Depends on what you really want to display and how your data / database looks like.
If you have a single and more or less simple database table, have a look atQSqlTableModel
or even
QSqlQueryModel
, for even more simple, read-only SQL database access queries.For anything further than that, you probably need to write your own database model + view (to change/insert data using your graphical representation of your data).
1/3