[Qt-interest] Checkbox in the header of a model?

Dario Ahdoot dario.ahdoot at image-metrics.com
Mon Apr 20 21:12:45 CEST 2009


Hi Andreas, thanks for answering.

I am surprised to hear that you have never seen a checkbox in a header. I have seen it many times (sadly I can't think of any of them now). It is used to change the state of all of the rows in that column all at once instead of having to click on each row individually. Also, the header checkbox will show the collective state of the checkboxes in all of the rows. i.e. if all rows are checked/unchecked, then the header will be checked. If there is a mix of checked and unchecked, then the header's checkbox will be in the "indeterminate" state.

Anyways, thanks.

Dario

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Andreas Pakulat
Sent: Monday, April 20, 2009 11:52 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Checkbox in the header of a model?

On 20.04.09 11:42:23, Dario Ahdoot wrote:
> I am trying to put a tri-state check box in the header of one of the columns of my QAbstractItemModel classes, but am finding that it doesn't seem to be possible. I am overriding QAbstractItemModel::headerData and checking for Qt::CheckStateRole  but that role never seems to get passed in. Is there any way to achieve this?

No, the reason is that flags() are not used for header data items, so
the headerview doesn't know that its items are checkable.
 
> Searching Qt docs and google in general seems to have no mention of this. I imagine this feature is so common that Qt would support it out of the box, but I guess I'm wrong.

Quite frankly I can't think of any application right now that I've ever
used that had checkboxes in the header. So personally I'm not surprised
that Qt Model/View doesn't support this out of the box.

Andreas

-- 
Good news.  Ten weeks from Friday will be a pretty good day.
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list