views:

39

answers:

1

Hi,

I have QTreeWidgetItem set in a QTreeWidget with 2 columns. Both cells got a CheckBox set by setCheckState(...).

When the user unchecks the CheckBox in my first column I uncheck the second CheckBox in column 2.

Now, I would like to prevent the user to check this second CheckBox again. Is it possible to remove this CheckBox in column 2 or to disable only this cell? So far I have just seen that all the flags work on the complete item and a set CheckBox won't disapear.

Btw. The items are not editable and I don't want to use a QTableWidget/-Item.

A: 

The CheckBox will be automatically inserted by Qt when I call setCheckState for the item:

QTreeWidgetItem *item = new QTreeWidgetItem(ui.TreeWidget);
item->setCheckState(0, Qt::Checked);

After the new the item does not own a CheckBox (by Qt default). Calling setCheckState(...) I automatically insert a CheckBox (here in column 0) with the Qt::CheckState I want.

But after I have done it there's no way to remove the CheckBox - so it seems.

Maybe anyone got a solution how I can get rid of this CheckBox at a later time? Any help is much appreciated! Thanks for your time...

Herbert Burowsky