Friday, 15 February 2013

qt - QSortFilterProxyModel breaks columnWidths -


What is the standard practice in maintaining column width in a QTableView that hides some columns / a QSortFilterProxyModel arbitrary command)? Note that I am talking about being hidden and unaware of them in an example.

I have tried several methods (all ugly) to go to it. Of course I am doing something wrong.

I have looked at QHeaderView :: saveState () and QHeaderView :: restoreState (), but until I'm missing nothing, it's really good to save only to start the shutdown. Once the columns are hidden in different order and are not missed, it breaks.

QSortFilterProxyModel works fine using filterAcceptsColumn (). A warning occurs when filterAcceptSColumn () returns right on a column that was previously returned fake. Although I run invalidateFilter () and it is portrayed in QTableView, the QTortVilterProxyModel column is using some default values ​​(100 sounds) for the width of the QTableView column before being hidden.

Thoughts?

Yes, use setSectionHidden () instead < P> In general, you should try to keep the code from outside the model (such as when showing / hiding columns on runtime) in our applications we have QTableView and QHeaderView Sub classes that allow the user to show / hide columns using the context menu; Column width (and also more) are not touched when hiding / hiding them.

FilterAcptsptsColumn can be used to completely disable columns like the primary key, the foreign key.

No comments:

Post a Comment