[Interest] new TableView columns hiding

Shawn Rutledge Shawn.Rutledge at qt.io
Wed Oct 24 10:26:58 CEST 2018


> On 24 Oct 2018, at 09:24, Vlad Stelmahovsky <vladstelmahovsky at gmail.com> wrote:
> 
> Hi all
> 
> investigating new TableView, added to 5.12 and have a question: is it possible to hide some columns dynamically w/o modify model?
> 
> bruteforce way to set column width to 0 doesnt works, because its checking width and force set it to some minimal value (have no idea, why)

Why: because the layout algorithm could have a bad edge case if some columns are zero-width.  (It keeps trying to fill the width of the view, but maybe it will never get there?)

I ran into that while preparing for my QtWS talk about TableView.  But I needed to subclass QSortFilterProxyModel anyway, to have sorting and filtering; so it was also not too hard to change the columns there by overriding mapFromSource and mapToSource.  You could think of your QSortFilterProxyModel subclass as a “view model”, and use it do whatever corrections you need to make to the original model to make it presentable.  At least that’s what I came up with for now.

https://github.com/ec1oud/qps/blob/unsquashed/qtquick/sortfilterprocessmodel.cpp



More information about the Interest mailing list