QSqlRelationalTableModel with two ComboBox independent



  • hi all
    I have table(area charge) with is one table between area and charge, one area have many charges and one have charge belongs to one area,my objective is filter the QComboBox charge the select the QCombox area what show all charge the area.
    Code here
    @
    modelAreacharge = new QSqlRelationalTableModel(this);
    modelAreacharge->setTable("area_charge");
    modelAreacharge->setRelation(modelAreacharge->fieldIndex("id_area"),QSqlRelation("area_trabajo","id_area","name"));
    modelAreacharge->setRelation(modelAreacharge->fieldIndex("idcharge"),QSqlRelation("charge","idcharge","name"));

    ui->comboBox_area->setModel(modelAreacharge->relationModel(modelAreacharge->fieldIndex("id_area")));
    ui->comboBox_area->setModelColumn(1);
    modelAreacharge->setFilter("id_area = 2");//filter area for chages
    ui->comboBox_charge->setModel(modelAreacharge->relationModel(modelAreacharge->fieldIndex("idcharge")));
    ui->comboBox_charge->setModelColumn(1);
    

    @



  • And the question is...?


Log in to reply
 

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