[solved] How to expand widget in other widget without using layout?



  • Hi,
    I have one widget (QWidget) that contains QScrollArea widget (I needed scroll bars for my program).
    I have problem with QScrollArea that doesn't fit to its parent (QWidget) - area should have the same size as QWidget. Probably I can do this by installing a resizing filter, but I was wondering if there is other way to do this?
    I can't use layout, because my QWidget could be resized to its minimum size (until I don't see any childs inside it, practically the height is near to 0). When I use layout I can't resize widget to minimum because scrollbars prevent from this - in that situation I can minimize QWidget only to size when scrollbar is minimum.
    I don't know if I explain it clearly, but if not please write I will try to do this better.


  • Moderators

    did you notice "QScrollArea's 'widgetResizable' property":http://doc.qt.io/qt-5/qscrollarea.html#widgetResizable-prop ?
    If i understood you correct thats what you want... but probably i did not :)



  • just reimplement resizeEvent() in your containg QWidget, and get the geometry of your contained QScrollArea manually in that code.



  • Raven-worx: setting widgetResizable to true allows to resize QScrollArea to it child widget (I assume that from docs). I want to resize that area to it's parent.

    Andre: Previously I was thinking about writing filter, but creating my own class that inherits QWidget was the best solution, thanks.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.