

Now you can create a class responsible for database access. In the Additional Dependencies add Qt5Sqld.lib for Debug and Qt5Sql.lib for release. In VS linker settings is located in Properties/Configuration properties/Linker/Input. You need to do it if your compilation fails with unresolved external symbol error. If you don’t use QtCreator but another IDE, for example Visual Studio, your project may need setting linker dependency to QtSql.lib. It will link your project against QtSql module. Access database from Qt applicationĬreate new Qt project. Now we can create C++ application to play with it. Sqlite> CREATE TABLE people(ids integer primary key, name text) Ĭongrats, your database is ready. To leave the sqlite console just type “.quit”.

It cointains a key (integer) and name (text). With sqlite you can create such a simple database with two console commands. Let’s assume, for simplicity, that we need to store people data - only name and corresponding id. Read more about sql drivers… Design and create the database Error should be followed by a console output that informs you which drivers you have installed: “QSqlDatabase: available drivers:”. If you face problems like “QSqlDatabase: QSQLITE driver not loaded” you need to install drivers manually. Depending on your distribution, you can have the drivers installed by default with your Qt or not. Qt requires drivers to deal with SQL databases. I have chosen SQLite engine because it’s the easiest engine to set up (it requires no server, no configuration…), still it’s suitable for the most of possible applications.

Here is some short example that presents how to do it. public Helper(Context context) : base (context, _DatabaseName, null , 1) Users." , ToastLength.Short).Accessing SQL databases from C++ applications is very simple with Qt library.private static string _DatabaseName = "clientDatabase".
