[Qt-interest] how to set the QTableWidgetItem to Qt::PartiallyChecked?

Andre Somers andre at familiesomers.nl
Thu Aug 26 09:23:36 CEST 2010


Op Do, 26 augustus, 2010 8:38 am, schreef lvbing lvbing:
> hi
>
> I create a QTableWidget and setItem  with the QTableWidgetItem. also I set
> the QTableWidgetItem flags include the Qt::ItemIsTristate.
>
> When I set the QTableWidgetItem setCheckState( Qt::PartiallyChecked ), or
> Qt::Checked,my table item can displayed fine!
>
> But when I click table item,it can only switch Qt::UnChecked or
> Qt::Checked,and I can't select the state Qt::PartiallyChecked.
>
> is the bug?and how to deal it ?

No, this is by design.
The idea of a partially checked item, is that it is used to indicate that
one or more of it's child items are checked, but not all of them. While
you can change all of them to checked, or all of them to unchecked with a
single action, there is no way to only check part of them with a single
action. Which ones to check then?

That is the reason you can only set this state programatically by default.
If you want to cycle through all three states (and you have an idea how to
assign a meaning to that "partial" state that will make sense to your
users), then you can probably create that behaviour by making  your own
delegate.

André




More information about the Qt-interest-old mailing list