Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
Deleting data from a database in Qt
This example shows you how to delete data from an SQLite database in Qt.
The table 'person' has the following columns:
- id (integer primary key), this is an autoincrement field
- firstname (varchar(20))
- lastname (varchar(30))
- age (integer)
- Qt is installed on your platform.
- More information about Qt on Maemo can be found here: Qt4 Maemo port
For Maemo SQLite development, the following packages must be installed:
Delete a person from the database:
The rest of the code:
// Find QSLite driver
db = QSqlDatabase::addDatabase("QSQLITE");
// NOTE: We have to store database file into user home folder in Linux
path = QDir::toNativeSeparators(path);
// NOTE: File exists in the application private folder, in Symbian Qt implementation
// Open databasee
A person's data is deleted from the database.
- Creating an SQLite database in Qt
- Creating a database table in Qt
- Inserting a row into a database in Qt
- Searching for data in a database in Qt
- Selecting data from a database without using SQL statements in Qt
- Using QDataWidgetMapper to show data from a database in Qt