Discussion:
[Interest] new TableView columns hiding
Vlad Stelmahovsky
2018-10-24 07:24:29 UTC
Permalink
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)


br,

Vlad
Shawn Rutledge
2018-10-24 08:26:58 UTC
Permalink
Post by Vlad Stelmahovsky
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
Christian Ehrlicher
2018-10-24 16:05:28 UTC
Permalink
Post by Vlad Stelmahovsky
ue (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?)
You not talk about QHeaderView but I think the codebase may be derived
from it:

void QHeaderView::resizeSection(int /logicalIndex/, int /size/)
Resizes the section specified by /logicalIndex/ to /size/ measured in
pixels. The size parameter must be a value larger or equal to zero. A
size equal to zero is however not recommended. In that situation
hideSection <http://doc.qt.io/qt-5/qheaderview.html#hideSection> should
be used instead.


Christian
Vlad Stelmahovsky
2018-10-24 16:14:26 UTC
Permalink
just to clarify, its about QML's TableView, not widget's QTableView
Post by Christian Ehrlicher
Post by Vlad Stelmahovsky
ue (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?)
You not talk about QHeaderView but I think the codebase may be derived
void QHeaderView::resizeSection(int /logicalIndex/, int /size/)
Resizes the section specified by /logicalIndex/ to /size/ measured in
pixels. The size parameter must be a value larger or equal to zero. A
size equal to zero is however not recommended. In that situation
hideSection <http://doc.qt.io/qt-5/qheaderview.html#hideSection>
should be used instead.
Christian
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
Loading...