QSqlRelationalTableModel not working when having two relations to same table



  • I use QSqlRelationalTableModel to show data. It does not show any data if I uncomment

    // mpCustomerModel->setRelation(18, QSqlRelation("CountryMaster", "code", "name")); in the below code. Is there something wrong?

        mpCustomerModel = new QSqlRelationalTableModel(this);
        mpCountryModel  = new QSqlTableModel(this);
    
        if (NULL != mpCustomerModel)
        {
            mpCustomerModel->setTable("CustomerMaster");
            mpCustomerModel->setRelation(15, QSqlRelation("CountryMaster", "code", "name"));
    //        mpCustomerModel->setRelation(18, QSqlRelation("CountryMaster", "code", "name"));
            mpCustomerModel->select();
    
            ui->customerComboBox->setModel(mpCustomerModel);
            ui->customerComboBox->setModelColumn(1); 
    

Log in to reply
 

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