[Qt-interest] QDataWidgetMapper and QSqlRelationalTableModel without some column

jjDaNiMoTh jjdanimoth at gmail.com
Tue Feb 23 12:26:48 CET 2010


2010/2/23 jjDaNiMoTh <jjdanimoth at gmail.com>:
> I don't know if with other Sql driver (like sqlite) it works or it
> give same error. I will try in the afternoon.

In the mainwindow constructor, using these lines as db initializer,
show (to me) that the same problem persist also with SQLite.

#ifdef UPOSTGRES
    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    db.setHostName("localhost");
    db.setDatabaseName("helpme");
    db.setUserName("postgres");
    db.setPassword("postgres");
    bool ok = db.open();
#else // UPOSTGRES
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(":memory:");
    bool ok = db.open();

    QSqlQuery query;
    query.exec("create table address (id int primary key, name
varchar(128), city_id int)");
    query.exec("create table city (id int primary key, name varchar(128))");
    query.exec("INSERT INTO city(id, name) VALUES(1,'Madrid')");
    query.exec("INSERT INTO city(id, name) VALUES(2,'Rome')");
    query.exec("INSERT INTO city(id, name) VALUES(3,'Paris')");

    query.exec("INSERT INTO address(id,name,city_id) VALUES(5,'Me',2)");
    query.exec("INSERT INTO address(id,name,city_id) VALUES(6,'You',1)");
    query.exec("INSERT INTO address(id,name,city_id) VALUES(7,'Him',3)");
#endif


-- 
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html



More information about the Qt-interest-old mailing list