Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issues with table model - Using Qcheckbox for boolean fields and I cannot insert or delete records...
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 412 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zeroptr
    wrote on last edited by zeroptr
    #1

    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..

    }

    Linux Mint 20.04 64 Bit QT6.0.1

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      zeroptr
      wrote on last edited by
      #2

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

      Linux Mint 20.04 64 Bit QT6.0.1

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved