jeudi 13 août 2015

Can I convert bool in model to yes/no in a QComboBox

I have a database with a column value 0/1.

I use QSqlRelationalTableModel for showing data to widget.

Is it possible to show Yes for 1 and No for 0 in a QComoboBox? And also, when I select yes/no, it should save to DB as 1/0.

Can I do something with setData() and getData() functions? Could someone give a clue how to start?

UPDATE:

    mpCountryModel->setTable("CountryMaster");
    mpCountryModel->select();

    ui->comboBox->setModel(mpCountryModel);
    ui->comboBox->setModelColumn(5);

As in column 5 has value 0 or 1, the same will display 0 and 1, right?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire