Results 1 to 9 of 9

Thread: QScrollArea and resizing

  1. #1
    Join Date
    Jun 2007
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QScrollArea and resizing

    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...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollArea and resizing


  3. The following user says thank you to wysota for this useful post:

    Cupidvogel (3rd February 2016)

  4. #3
    Join Date
    Jun 2007
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QScrollArea and resizing

    ...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...

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollArea and resizing

    Can you post a screenshot? Please make sure the boundaries of the inner widget are visible.

  6. #5
    Join Date
    Jun 2007
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QScrollArea and resizing



    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
    Qt Code:
    1. QSize QtTimeLine::sizeHint() const
    2. {
    3. return QSize(frames * zoom + 2, 40);
    4. }
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. QSize QtTimeLine::sizeHint() const
    2. {
    3. return QSize(frames * zoom /*+ 2*/, 40);
    4. }
    To copy to clipboard, switch view to plain text mode 

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

    I'm a bit confused here

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollArea and resizing

    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()?

  8. #7
    Join Date
    Jun 2007
    Posts
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QScrollArea and resizing

    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!

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QScrollArea and resizing

    Where did you call updateGeometry? Could you provide a minimal compilable example reproducing the problem?

  10. The following user says thank you to wysota for this useful post:

    Cupidvogel (3rd February 2016)

  11. #9
    Join Date
    Jun 2007
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QScrollArea and resizing

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.