[Interest] QTreeWidget with fixed or min row height

Bo Thorsen bo at vikingsoft.eu
Mon Mar 16 17:56:26 CET 2015


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.

Bo Thorsen,
Director, Viking Software.

-- 
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu



More information about the Interest mailing list