[SOLVED] QSqlRelationalTableModel and "Lazy population"



  • Good day everyone .
    Could somebody tell me why when I have

    @
    /Connection.h/

    bool connection () {
    QSqlDatabase con = QSqlDatabase::addDatabase ("QMYSQL");
    con.setHostName("192.168.1.116");
    con.setUserName("bacula");
    con.setPassword("****");
    con.setDatabaseName("test");
    if (con.open () ) {
    qDebug() << "Connection OK";
    }
    }@

    @
    /*MAIN.cpp */
    Connection();
    QSqlRelationalTableModel * model = new QSqlRelationalTableModel();
    model->setTable("MAIN");
    model->setRelation(2,QSqlRelation("Prop_Org","Code","OrgName"));
    model->setRelation(1,QSqlRelation("Prop_Vid","Code","VidName"));
    model->setRelation(5,QSqlRelation("Sources","Code","Name"));
    model->select() ;
    QTableView * view = new QTableView ();
    view->setModel(model);
    view->show();@

    I DON'T have "lazy population" ,but if i replace Connection.h by Connection_ODBC.h which is using ODBC driver ,

    @
    /connection_ODBC.h/

    bool connection () {
    QSqlDatabase mbase = QSqlDatabase::addDatabase("QODBC");
    mbase.setDatabaseName("Paradox");
    if ( mbase.open() )
    qDebug()<< QString ("Paradox connection OK ");
    }
    @

    every works fine .
    Is it could happens because in first time i using Mysql and in second Paradox ? ( data in database the same , i make a migration from Paradox to Mysql and trying to have the same behavior)
    Maybe I miss something ? Please I need your advice .
    thank you for your time and forgive me my English it is not my native .



  • Ok I resolve it my self , the trick was in my database
    "Lazy population" doesn't work if
    @QSqlDriver::hasFeature(QSqlDriver::QuerySize)@ return true
    Hope this may help somebody .



  • Add “[SOLVED]” to the topic’s title :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.