[Interest] QTreeWidget with fixed or min row height

Duane duane.hebert at group-upc.com
Mon Mar 16 18:12:15 CET 2015


On 16/03/2015 12:56 PM, Bo Thorsen wrote:
> Den 16-03-2015 kl. 17:47 skrev Duane:
>> I'm trying to set up a tree widget where I can resize the column width
>> to content but maintain a fixed row height.
>>
>> I have a custom delegate which I use to paint cell borders and I've
>> added an overload to QSizeHint for this. I've also tried just setting
>> the size hint but in either case column height works but the width
>> doesn't size properly.
>>
>> Is there a way to achieve setting the tree's resize mode to resize to
>> contents but also setting the height?
>
> Hi Duane,
>
> You can emit the dataChanged for the cell and change the SizeHintRole.
>
> The problem with this is that the model now needs UI information so it
> gets tightly coupled with a single view widget, but that's a known
> design issue with those classes. If you need this model to be visible
> for multiple views, you have to use a proxy model to set the size hint.
>


Thanks for the reply.  For the moment I'd like to avoid this coupling. 
I can easily resize the sections based on the widest text.  But I was 
looking for a way to make the tree set a min or fixed row height without 
looking at the data.





More information about the Interest mailing list