tags:

views:

538

answers:

1

I have a QTableView and a QStandardItemModel. Is there have a column can contain checkboxes that are user editable without using delegates or using the abstract model classes? Not that I cant do it i just want to minimize the code, I would find it overkill for simple check boxes.

By using model.setData(index, Qt::Unchecked,Qt::CheckStateRole) this creates the checkbox but it is not user editable (text beside checkbox is)

i used modelTX.setData(index, FALSE) but this creates a combo box containing True and False.

ill try setItemData

+1  A: 

pls, check if the following example would work for you:

QStandardItemModel* tableModel = new QStandardItemModel();
// create text item
tableModel->setItem(0, 0, new QStandardItem("text item"));
// create check box item
QStandardItem* item0 = new QStandardItem(true);
item0->setCheckable(true);
item0->setCheckState(Qt::Checked);
item0->setText("some text");
tableModel->setItem(0, 1, item0);
// set model
ui->tableView->setModel(tableModel);

hope this helps, regards

serge_gubenko
thx for the reply. I will tr it on monday when i come back to work but I think it will work.
yan bellavance