PDA

View Full Version : Looking for simple way to integrate a Database



TurnX
6th April 2010, 21:46
Currently I am working on a project for a business systems class that at its base level will take information from a database, apply some algorithms to it, and display it to the user through a GUI. I am also taking a class that teaches OO C++ using Qt and as I really enjoy using it I would like to use Qt to develop my program for my other class.

So basically my question is what is the easiest way to integrate a simple database into my Qt program, one that I can read and write to. I have experience with MySQL, and I believe there is support in Qt for that, but since I am not experienced with it I was hoping someone with a little more experience could help me out.

waynew
6th April 2010, 22:59
Qt comes with SQLite built in. Just add QT += sql to your pro file.
See here: http://doc.trolltech.com/4.5/qtsql.html and here: http://www.hwaci.com/sw/sqlite/docs.html

TurnX
6th April 2010, 23:45
Thats exactly what I am looking for, thank you. One other question I have though is how exactly should I create the database? I have worked with online sql databases before when doing some web design, using php in html to execute queries, but what is the best method here? Should I create one online and connect to it there? Or is there a way I can create one locally?

Lykurg
7th April 2010, 07:29
You are free to create your database locally or somewhere else. It depends on the needs of your application. Simple use the QSqlDatabase and define the necessary connection details (local or in the internet). If you need a local database I would go with SQLite for the beginning.