weird update behavior with QSQLRealtionalTableModel



  • Hi All,

    I have a main table like this.. on postgresql

    CREATE TABLE t_module_rights
    (
    u_name d_kod NOT NULL,
    t_module_id d_id_field NOT NULL,
    module_right boolean NOT NULL,
    CONSTRAINT pki_module_rights PRİMARY KEY (u_name, t_module_id),
    CONSTRAINT fk_mr_t_module FOREİGN KEY (t_module_id)
    REFERENCES t_module (module_id) MATCH SIMPLE
    ON UPDATE NO ACTION ON DELETE CASCADE,
    CONSTRAINT fk_mr_t_user FOREİGN KEY (u_name)
    REFERENCES t_users (u_name) MATCH SIMPLE
    ON UPDATE CASCADE ON DELETE CASCADE
    )
    WITH (
    OIDS=FALSE
    );
    CREATE TABLE t_module
    (
    module_id d_id_field NOT NULL,
    m_name d_ack,
    CONSTRAINT pki_modules PRİMARY KEY (module_id)
    )
    WITH (
    OIDS=FALSE
    );

       modHak = new QSqlRelationalTableModel(this,cn::db());
        modHak->setTable("t_module_rights");
        modHak->setRelation(1,QSqlRelation("t_module","module_id","m_name"));
        modHak->select();
        modHak->setHeaderData(1,Qt::Horizontal,"Modul Adı");
        modHak->setHeaderData(2,Qt::Horizontal,"Hak Var/Yok");
        ui->tbl_User_Hak->setModel(modHak);
        ui->tbl_User_Hak->hideColumn(0);
    

    I relate module_id with the name... When I try to update data on the tableView it cannot properly update the data and if I try to update another row it does nothing.. I think problem couses from the table becouse it uses two field primary key.. The source of this idea other classes doesn't have any problem like this..

    1. question
      is there any way to make a QSQLQuerymodel updateable?
      for this kind of tables?


  • Hi all,

    QSqlRelationalTableModel or QSqlTableModel cannot handle multiple field primary keys...

    my guess is right..


Log in to reply
 

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