[Qt-interest] QSql doubts
Yuvaraj R
yuvaraj at ongobiz.com
Fri Jul 17 13:18:54 CEST 2009
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
QSqlDatabase <http://doc.trolltech.com/latest/QSqlDatabase.html> db =
QSqlDatabase <http://doc.trolltech.com/latest/QSqlDatabase.html>::addDatabase("QSQLITE");
db.setDatabaseName(":memory:");
if (!db.open()) {
return;
} QSqlQuery <http://doc.trolltech.com/latest/QSqlQuery.html> query;
//query.exec("create table yuvaraj ( id int , name varchar(20000))");
query.exec("insert into yuvaraj values(1000,'"+QString
<http://doc.trolltech.com/latest/QString.html>(str)+"')");
model = new QSqlRelationalTableModel
<http://doc.trolltech.com/latest/QSqlRelationalTableModel.html>(this);
model->setTable("yuvaraj");
model->select();
QMessageBox <http://doc.trolltech.com/latest/QMessageBox.html>::information(0,"1",QString
<http://doc.trolltech.com/latest/QString.html>("yuvarj"));
mapper = new QDataWidgetMapper
<http://doc.trolltech.com/latest/QDataWidgetMapper.html>(this);
mapper->setModel(model);
mapper->addMapping(ui->textBrowser, model->fieldIndex("name"));
QMessageBox
<http://doc.trolltech.com/latest/QMessageBox.html>::information(0,"2",QString
<http://doc.trolltech.com/latest/QString.html>("yuvarj"));
mapper->toFirst();
there isan another way to create own database
:
QSqlDatabase <http://doc.trolltech.com/latest/QSqlDatabase.html> db =
QSqlDatabase <http://doc.trolltech.com/latest/QSqlDatabase.html>::addDatabase("QPSQL");
db.setHostName("customer");
db.setDatabaseName("customdb");
db.setUserName("yuvaraj");
db.setPassword("yuvaraj");
bool ok = db.open();
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090717/00ab4630/attachment.html
More information about the Qt-interest-old
mailing list