PDA

View Full Version : QScrollArea and resizing



rarefluid
18th June 2007, 13:37
Hello all.

I've got a problem with a qscrollarea not resizing properly.
I have the qscrollarea in a outer widget and another widget inside the qscrollarea. It is a custom widget that implements sizeHint() and minimumSizeHint().

I want the inner widget to always take up min. 100% of the visible space of the qscrollarea and the scrollarea to take up as much space of the outer widget as possible.

What does not work is when the inner widget resizes (gets smaller) the qscrollarea won't adjust (shrink). It stays the same size and show it's backgound... I tried using "scrollarea->resize(innerwidget->sizeHint())", but that didn't change much...

...hope you have some ideas...

wysota
18th June 2007, 14:29
Set QScrollArea::setWidgetResizable() to true.

rarefluid
18th June 2007, 14:40
...is already true...
I assume that there is a conflict between the qscrollarea trying to fill up the space in the outer widget and resizing to the inner widgets' size, but I don't really know how to resolve this...

wysota
18th June 2007, 15:55
Can you post a screenshot? Please make sure the boundaries of the inner widget are visible.

rarefluid
18th June 2007, 16:46
http://wurstcaptures.untergrund.net/Unbenannt.png

first/upper picture shows the original state. the "timelinish" widget inside the scrollarea is the inner widget mentioned. when I resize the whole window, the inner widget grows with the scrollarea (see second picture). When I use the spinbox to change the displayed duration of the timeline, the inner widget calls "update()" for itself, which repaints the widget.

I actually made it rescale to a smaller size when you change the window size


QSize QtTimeLine::sizeHint() const
{
return QSize(frames * zoom + 2, 40);
}

to


QSize QtTimeLine::sizeHint() const
{
return QSize(frames * zoom /*+ 2*/, 40);
}


But I can't get it to rescale when I change the size internally...

I'm a bit confused here :o

wysota
18th June 2007, 16:57
Please don't use external sites to host images you use in your posts. Use the attachment feature of the forum instead.

In what way you change the size "internally"? Do you inform Qt that the sizeHint changes by calling QWidget::updateGeometry()?

rarefluid
18th June 2007, 17:15
Ok. Sorry for the external link.

I change the member variables I keep internally which makes "sizeHint()" return a different value... In the function that gets called upon change of the widget iI call "update()" to repaint the widget. I tried "updateGeometry()" but that didn't change anything...

Thanks for the help so far!

wysota
18th June 2007, 17:22
Where did you call updateGeometry? Could you provide a minimal compilable example reproducing the problem?

denis.bz
22nd July 2007, 14:18
Try
setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
like examples/widgets/imageviewer.

or MinimumExpanding ? see the doc for QSizePolicy --
QSizePolicy::MinimumExpanding should get as much space as possible
QSizePolicy::Ignored will get as much space as possible

It's not clear to me if Ignored really means ignore the sizeHints too.
Can any expert describe how sizeHints work ?
walk the widget tree, getting min / preferred / max sizes
layout engine ..

Fwiw google "Qt scrollarea bug" has several hits, versionitis ?

cheers