The Best Place to Start Qt Database Interface

I was asked about using the Qt database interface for Oracle.

What's a good starting point for learning this? Do you have any experience with him that you can share?

+2


source to share


1 answer


We have been using the QtSql classes for several years now, we are currently using an ODBC driver to connect to an MSSql instance. In general, the entire interface does this reasonably well. It completely isolates you from the database drivers QSqlDatabase

, QSqlQuery

and QSqlResult

, there are some abstractions that also isolate you from the actual SQL QSqlTableModel

and QSqlRelationalTableModel

, but they are meant to be used in any Qt view. There is also a classQDataWidgetMapper

which helps to display data in non-table views. In addition, QVariant does an excellent job of wrapping the SQL data and providing typed access to the query result. While this is all very useful, unless your application is small in scope, it won't save you from having to come up with a decent DAO level, none of the Qt classes provide this.

We have a process where we turn a custom made-xml description into an sql script to create a table, a qt wrapper class for QSqlRecord

, and we use QSqlTableModel

for most of our work with CRUD. This works well enough, but there is a lot of overhead in these classes, so I would not repeat this approach.



We found some quirks with the ODBC driver, I'm sure there are other quirks with the oracle driver too. OTOH we are fairly confident that within a short period of time we can switch from MS-SQL to ORACLE.

As for the initial values, I think there is a simple example in the qt examples.

+2


source







All Articles