[Development] sizeHint for QAbstractScrollArea, especially item views

Stephen Kelly stephen.kelly at kdab.com
Fri Jan 6 09:08:40 CET 2012


On Thursday, December 22, 2011 18:06:51 Christoph Schleifenbaum wrote:
> Hi,
> 
> currently, item views do return a rather random size hint. Some at KDAB,
> including me, would love to see a size hint actually being related to the
> scroll area's content. For this, we thought of a method viewportSizeHint
> which returns the size of the viewport as if there would be no scroll bars
> required.
> 
> The most common use case for this is a list or a table of data in a window:
> 
> a) The ui designer doesn't need to set a custom size for the view, the size
> hint will make sure all data are visible
> 
> b) The amount of data might grow, in that case it might made sense to
> enlarge the view. Imagine three tree views below each other inside a scroll
> area. If the tree views would stay at their size, a scroll bar would appear
> in both the tree view and in the surrounding scroll area. This won't happen
> with a proper size hint combined with a size policy.
> 
> I'v attached a patch to the current qtbase.git. It does the described
> behaviour for QScrollArea and QTableView. Try running the example at
> examples/itemviews/spreadsheet to see what happens if you e.g. resize the
> columns in the table view.
> 
> 
> Thoughts?


Just bumping this.

The patch is in Gerrit 

http://codereview.qt-project.org/#change,11763

Apart from the layouting use case, the method would make it easier to 
implement 'Frozen columns' in itemviews using multiple views which interact 
with each other. I know that there is an example in Qt for that, but that has 
some inflexibility, such as it needs to call

       setHorizontalScrollMode(ScrollPerPixel);
       setVerticalScrollMode(ScrollPerPixel);
       frozenTableView->setVerticalScrollMode(ScrollPerPixel);
so you are no longer in control of your scroll mode.

This proposed method would make it possible to implement the scrollbars 
properly on the container view (which is the issue the example dodges). 

Thanks,

-- 
Stephen Kelly <stephen.kelly at kdab.com> | Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120106/809d7205/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120106/809d7205/attachment.sig>


More information about the Development mailing list