0

This seems something that should be very simple, but for whatever resason I've been looking for a solution for hours now.

Here is example window: enter image description here

The buttons are on a grid layout. Grid layouts right side ends where right buttons end. When I resize the window at runtime I want buttons to scale down with the window. Instead buttons stay the way they are and I get this:

enter image description here

I have found many examples with c++, but nothing that works with PyQt.

Heikki
  • 341
  • 2
  • 18
  • 1
    You've added the layout from the widget box, but those layouts are intended for layout nesting (adding a child layout to an existing one) or "floating" widgets. To set the main layout of a window or container widget, you have to right click on an empty area it and select the appropriate item from the "Lay out" submenu. See the [documentation on using layouts in Designer](https://doc.qt.io/qt-5/designer-layouts.html). – musicamante Dec 17 '22 at 00:53
  • Thanks I tried it again. When I tried it earlier layout options of the QMainWindow were unavaiable (greyed aout). The key difference was that now I had stuff (buttons) already on that layout. So In my case I had to first add elemts to the parent without layout and after that add them to layout. This seems odd. If the QGridLayout for instance is parent to buttons why do I have to create childrens before parent can be implemented? I'm sure I am still aproaching it from the wrong angle, but at least now it works as intended. Thank you @musicamante. – Heikki Dec 17 '22 at 08:57
  • The layout is not parent of the widgets, it only manages their geometries. The parent is the widget on which the layout is set (which could be the window or another widget). In any case, that's just how Designer works: in order to set a layout for a container, at least one widget must be added. – musicamante Dec 17 '22 at 18:30

0 Answers0