Important: Please read the Qt Code of Conduct -

[solved] Basic layout question

  • If I got a very simple widget based application with just one button in the lower right corner, how can I tell the button to stay in the lower right position even if the window is resized.

    In C#/Windows Forms, iOS, OSX you would tell the widget (which is called view there) to stay glued to the next thing that is right next to and beneath it.

    In Qt there seems to be a complete different paradigm: layouts should be what I a looking for. But somehow I don't get the drift how to use layouts for this fairly simple task. I guess it's simple, my way just needs to be rewired for the new way of approaching layouts 8)
    And yes, I've used the Forum search and Mr. Google ;-)

  • If you are using Qt Designer

    1. Drag n Drop a pushButton to the form.
    2. Then drag n drop a horizontal spacer.
    3. Select the spacer and the pushButton
    4. Then from the toolbar at the top select horizontal layout.
    5. Then drag n drop a vertical spacer to the form.
    6. Select the vertical spacer and the layout that has horizontal spacer and pushButton
    7. Then from the toolbar set the layout as vertical.

    Here is the image :


    You can check some "Video Tutorials": .

  • Ah, thank you. As I though: not complicated, just another way of thinking :-)

Log in to reply