[Interest] QTreeView, QHeaderview, ResizeToContents and Interactive

Etienne Sandré-Chardonnal etienne.sandre at m4x.org
Thu Mar 16 23:21:53 CET 2017


Hi,

You can resize the header sections programmatically after the first load.

for(int i=0;i<header->count();++i)
    header->resizeSection(i, header->sectionSizeHint(i));

This should do the job.

Cheers,

Etienne

2017-03-16 22:27 GMT+01:00 Alexander Semke <alexander.semke at web.de>:

> Hi,
>
> I have a QTreeView where after setting the model I call header()-
> >setResizeMode(QHeaderView::ResizeToContents) to adjust the column width
> to
> the content. Since I want the user to be able to resize the header sections
> manually, I call header()->setResizeMode(QHeaderView::Interactive) after
> this
> which squeezes the columns to the sizes where the content is not fully
> visible
> anymore. In my model in headerData() I don't calculate any sizes for the
> SizeHintRole case.
>
> How can I achieve this behaviour (tree view columns automatically adjusted
> to
> the content after the initial load and manually resizable later) in the
> most
> easiest way?
>
> --
> Alexander
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170316/3e1b4dc6/attachment.html>


More information about the Interest mailing list