PDA

View Full Version : Trying to control QScrollArea / QAbstractScrollArea sizing logic



cboles
30th April 2010, 06:22
First let me describe my goal. I have a Qt application that displays a number of toolbar-like floating windows that are sized according to the data the contain, and also resize dynamically when the user requests help or wants to display a graph (see the first set of images for examples). I make use of a number of layout, view, and widget classes to pull this off, but all this has worked well for some time.

4569
4572
4573

The problem is that some tables can be too large for some user's laptop screens, and so I wanted to fix this by adding on-demand scroll bars that only appear when the window is too large for the screen in either one or both axes.

After sub-classing QScrollArea to get rid of the silly


return sz.boundedTo(QSize(36 * h, 24 * h));

size clipping that they do in their sizeHint() to artifically limit the maximum hinted size, and instead creating limits that are close to the current screen size, I am able to get my desired result.

4571

The problem now is an undesirable side effect: All of my windows are sized correctly after the initial layout process is completed - exactly like the images I have shown above, BUT if the user takes any actions which cause the viewport contents to grow (by turning on the help text for example), the window does not resize like it used to, and instead just adds scrollbars, even though I am no where near my sizeHint() clipping limit that I have set.

4570

It would seem that whatever logic is used in the initial layout sizing (which works perfectly) is not the same as what happens when widgets and layouts get resized later. Does anyone know what the culprit is here or where I should look? Trying to debug layout calls really isn't fun...

Colby