[Qt-interest] Checkbox in the header of a model?
Dario Ahdoot
dario.ahdoot at image-metrics.com
Mon Apr 20 21:30:53 CEST 2009
Clint was nice enough to share this with everyone. Thanks!
-----Original Message-----
From: Clinton Stimpson [mailto:clinton at elemtech.com]
Sent: Monday, April 20, 2009 12:29 PM
To: Dario Ahdoot
Subject: Re: [Qt-interest] Checkbox in the header of a model?
Or better, the link to it.
<http://public.kitware.com/cgi-bin/viewcvs.cgi/Qt/Widgets/pqTreeWidget.cxx?root=ParaView3&view=log>
There's also the delegate approach someone else mentioned, but I don't
know if that's a simpler approach.
Clint
Dario Ahdoot wrote:
> Cool. Thanks! I still think this should be natively supported by Qt since this is IMHO a very common thing to do. Would you mind if I re-posted your source to the list to share?
>
> -----Original Message-----
> From: Clinton Stimpson [mailto:clinton at elemtech.com]
> Sent: Monday, April 20, 2009 12:20 PM
> To: Dario Ahdoot
> Subject: Re: [Qt-interest] Checkbox in the header of a model?
>
>
> It wasn't that hard. Attached is some code.
>
> Clint
>
> Dario Ahdoot wrote:
>
>> That is what I was afraid of. However, that will require having a pixmap to match the native look for each system, blah blah blah. Not fun.
>>
>> -----Original Message-----
>> From: qt-interest-bounces at trolltech.com
>> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Clinton
>> Stimpson
>> Sent: Monday, April 20, 2009 12:03 PM
>> To: qt-interest at trolltech.com
>> Subject: Re: [Qt-interest] Checkbox in the header of a model?
>>
>> 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?
>>>
>>> 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.
>>>
>>>
>>>
>> You can do it by setting a pixmap of the chechbox in with the
>> DecorationRole.
>> You'll have to control the pixmap yourself, with maybe the help of
>> QStyle for a native look.
>>
>> Clint
>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>> _______________________________________________
>> 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