On 20 May 2014, at 22:28, Andre Somers <an...@familiesomers.nl> wrote:

> Nurmi J-P schreef op 19-5-2014 14:29:
>> On 19 May 2014, at 12:51, Alexander Ivash <elder...@gmail.com> wrote:
>> 
>>> I was trying to use QML components in simple android application but 
>>> confronted several issues:
>>> 
>>> 1. I couldn't find any API allowing to adjust widths of columns in 
>>> TableView based on the content. Do I understand right that the only way to 
>>> achieve this is to go through all the entries in model manually and 
>>> calculate maximum width using 'paintedWidth' of Text element? Does the 
>>> better way exist? For future would be really nice to have some property 
>>> like 'autoAdjustColumns’.
>> QtQuick.Controls 1.2 (Qt 5.3) introduces TableView::resizeColumnsToContens() 
>> and TableViewColumn::resizeToContents().
> Stupid question probably, but why arn't these written in a declarative way?
> 
> André

Certainly not a stupid question and I think I could pitch in on why I think 
they are done this way. 

Just like with widget item views, adjustToColumns only adjusts to the currently 
visible content as it involves querying all the visible items for their 
implicit size hints and adjusting to the largest one. This is also what happens 
when the user double clicks on a column resize handle. Remember that table view 
doesn’t know the size hints of the potentially millions of items that are yet 
to be scrolled into view.

An imperative approach lets the user decide exactly when the columns should be 
adjusted, which is usually right after setting the model.

In addition, the user generally does not expect table view headers to expand or 
change while they are scrolling the table view. If this was a declarative 
property, you would either not have any control of exactly when to do so and 
the alternative would be to continuously adjust to contents during scrolling 
which would also carry a big performance cost.

Regards, 
Jens
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to