qtscrollqt-designer

Qt Designer: Unable to get scroll area to work properly


I used Qt Designer to create a layout. Because everything kept jumping around, I used groupboxes and horizontal/vertical layouts. The different sections should be of fixed size.

I have to make it all fit on a very small window... so I have to add all my groups into a ScrollArea.

I have been trying to make it work... to make it show the scroll bars. Resizing it did not have any effect.

I read that I must apply a layout - I had a very hard time applying it.

I chose the grid layout - with group boxes delimiting the areas that must remain fixed.

Still resizing the scroll area either gave me no scroll bars, or resized the contents of my group boxes - covering up qgraphicviews and buttons, even though my thought was that the contents have to be shown...

I finally made it all work - with scroll bars - once I made every single groupbox of fixed size.

So - right now - I have

 Window    ---> QWidget (sizePolicy (Preferred, Preferred, 0, 0))
   scrollArea    ---> QScrollArea (sizePolicy (Preferred, Preferred, 0, 0);
                                   verticalScrollBarPolicy: ScrollBarsAsNeeded, same with horiz)
                                   widgetResizable: checked)
    scrollAreaWidgetContents   ---> QWidget  (layout: grid layout; 
                                    sizePolicy (Preferred, Preferred, 0, 0))
      grp1    ---> QgroupBox (sizePolicy (Fixed, Fixed, 0, 0))
        contents
      grp2    ---> QgroupBox (sizePolicy (Fixed, Fixed, 0, 0))
        contents
      ....

Still have a problem: I can resize the scroll area in the Designer, and set it to the size I will need. But even though the size is "Preferred" not "Fixed", once the program is running I can not resize the scroll area.

What I think the normal behavior should be: I should start with whatever the scroll area is, and hopefully I can set the window size to match the scroll area.

If I resize the window, the scroll area should follow.

What I see happening: The scroll area is of fixed size, and the window can be resized (but with empty area outside scroll area).

How can I make the scroll area still resize (and match the window, since it is the only object inside it) ?


Solution

  • Apply a layout to the Window QWidget (which layout, is irrelevant) and place the scroll area inside.

    (answering the last phase of my question so I don't have to delete it, after gradually figuring out how to make it work)