Hi All
I want to use QSql in my application to call History..
I have gone through the qt examples and documents and i tried small examples based the examples given with Sdk.
I want to store call history..
In examples i did like
db.setDatabaseName(":memory:");
if (!db.open()) {
return;
}
//query.exec("create table yuvaraj ( id int , name varchar(20000))");
query.
exec("insert into yuvaraj values(1000,'"+QString(str
)+"')");
model->setTable("yuvaraj");
model->select();
mapper->setModel(model);
mapper->addMapping(ui->textBrowser, model->fieldIndex("name"));
mapper->toFirst();
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(":memory:");
if (!db.open()) {
return;
}
QSqlQuery query;
//query.exec("create table yuvaraj ( id int , name varchar(20000))");
query.exec("insert into yuvaraj values(1000,'"+QString(str)+"')");
model = new QSqlRelationalTableModel(this);
model->setTable("yuvaraj");
model->select();
QMessageBox::information(0,"1",QString("yuvarj"));
mapper = new QDataWidgetMapper(this);
mapper->setModel(model);
mapper->addMapping(ui->textBrowser, model->fieldIndex("name"));
QMessageBox::information(0,"2",QString("yuvarj"));
mapper->toFirst();
To copy to clipboard, switch view to plain text mode
there isan another way to create own database
db.setHostName("customer");
db.setDatabaseName("customdb");
db.setUserName("yuvaraj");
db.setPassword("yuvaraj");
bool ok = db.open();
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("customer");
db.setDatabaseName("customdb");
db.setUserName("yuvaraj");
db.setPassword("yuvaraj");
bool ok = db.open();
To copy to clipboard, switch view to plain text mode
i have one doubt .which method i have to use.if declare this code at constructor every time database and table is creating..
Where can i find good example based one QSql apart from examples.
Can you please suggest me
Thanks
Yuvaraj R
Bookmarks