Issues with table model - Using Qcheckbox for boolean fields and I cannot insert or delete records...



  • Hi all,

    I have a form that show users, like this form

    I want to show the boolean fields as QCheckbox but I could not manage it.. I read a lot of thinf about Item delegate Qabstractitemview etc but no luck..

    my code like this

    frmKULLANICI_TANIM::frmKULLANICI_TANIM(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::frmKULLANICI_TANIM)
    {
    ui->setupUi(this);
    modKullanici = new QSqlTableModel(this,cn::db());
    modKullanici->setTable("t_users");
    modKullanici->select();
    modKullanici->setHeaderData(0,Qt::Horizontal,"Kullanıcı Adı");
    modKullanici->setHeaderData(1,Qt::Horizontal,"Giriş Adı");
    modKullanici->setHeaderData(2,Qt::Horizontal,"Parola");
    modKullanici->setHeaderData(3,Qt::Horizontal,"Admin");
    modKullanici->setHeaderData(4,Qt::Horizontal,"Operatör");
    ui->tableView->setModel(modKullanici);
    dwmKullanici = new QDataWidgetMapper;
    dwmKullanici->setModel(modKullanici);
    dwmKullanici->addMapping(ui->txtKullaniciAdi,0);
    dwmKullanici->addMapping(ui->txtLogon,1);
    dwmKullanici->addMapping(ui->txtParola,2);
    dwmKullanici->addMapping(ui->chkAdmin,3);
    dwmKullanici->addMapping(ui->chkOperator,4);
    dwmKullanici->toFirst();

    }

    void frmKULLANICI_TANIM::on_btnEkle_clicked()
    {
    modKullanici->insertRow(-1); // do nothing on model... or screen..

    }



  • masterdetail example solved the problem for insert and delete ...
    I'm looking for a quick way to show checkboxes on grid..


Log in to reply
 

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