I can't set layout position
-
Hi everyone, i am new with PyQt, i am using QtDesigner
i created a Horizonal Layout, then i add a button to this layout.
When i run the code, i see that button is on the middle of GUI. Why does it happen? Why i don't see button on the position i set?
-
Hi,
Because you don't position a layout. The layout is set on the widget and then manages whatever you put in it following the rules of the layout type you are using.
-
@SGaist said in I can't set layout position:
Hi,
Because you don't position a layout. The layout is set on the widget and then manages whatever you put in it following the rules of the layout type you are using.
Thanks for reply,
I dont want to change positiont of button. Also i need to put button to a layout. Which layout type should i choose? -
Why do you want your button inside a layout since you don't want the behaviour offered by the layout ?
-
@SGaist Actually i tried to simply my problem with button. Here is the my original problem.
As you see, i have two frames and one frame (frame3) outside two frames. When i click set Lay Out in a Grid, frame1 disappears and when i maximize window. Size of widgests don't change. (sizePolicies are expanding)
This link is my referece (11:40) -
So you want the same behavior as in the video?!
What layouts did you set so far?
I dont believe that frame1 disappears, I guess it just shrinks due to expanding frame2.Btw: You can combine multiple layouts and layout types until you get, what you want to achieve. A GridLayout is not always the best solution. Especially if you want to have your button (optional: some spacers) your frame, which has its own inner layout, in one layout.
I made an example layout structure for another issue. Maybe it helps.
Here -
Frame 2: 2 QVBoxLayouts and 1 QHBoxLayout. Or one QGridLayout
Frame 1: it's not really clear what's inside of it.
Frame 3: One QGridLayout and the button in a QHBoxLayout, and you add a stretch after the button.
-
@SGaist said in I can't set layout position:
Frame 1: it's not really clear what's inside of it.
It is a label.
Frame 2: 2 QVBoxLayouts and 1 QHBoxLayout. Or one QGridLayout
I thought 2 QVBoxLayout. But when I put Widget to a layout I can't set its size, so I am confused. Which widgets should I put to QHBoxLayout
-
Please take the time to learn about the use of layouts.