Development/Tutorials/SqLite

< Development‎ | Tutorials
Revision as of 10:46, 10 November 2011 by Tstaerk (Talk | contribs)

Jump to: navigation, search
#include <QtSql>

int main(int argc, char *argv[])
{
    QSqlDatabase db;
    db=QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("sqlite.dat");

    if (db.open()) 
        qDebug() << "success";
    else 
        qDebug() << "failed";
    QSqlQuery query;
    query.exec("create table stocks(id int primary key, name varchar(20))");
    db.commit();
    db.close();
}
QT       += core gui sql

TARGET = sqlite
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

See also

http://doc.trolltech.com/4.5/sql-relationaltablemodel.html http://commits.kde.org/kdeexamples/23d2202b0e7aca8999928374746da5733712ebc8


KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal