Important: Please read the Qt Code of Conduct -

Size Policy of Push Buttons, inside a Layout

  • Hi,

    I started to explore QT Creator 4 days ago, and I absolutely love it.
    However I have an Issue with the Size policy of Push buttons.
    To get familiar with QT I wanted to start with something simple, and decided to
    Create a simple calculator, nothing fancy. The Pushbuttons should be square no matter what size the window is. Everything works fine but the Pushbuttons always stretch themselves horizontally at runtime if they are inside a layout, no matter what I use for Size Policy. Even if I use Fixed, or Ignore. It doesn't seam to matter what size policy I choose for the Buttons or
    The layout.
    Any idears what i might doing wrong?
    Thank you.

  • Moderators

    Try to put a horizontal spacer on the right side of your row of push buttons. A spacer will push the buttons to keep them at bay.

  • After reading thru some documented Examples I found out what is going on. In the FormEditor the Main Layout is not visible, thus you have to select it in the Hierarchy view. So every setting I changed in the Gridlayout and its children was overwritten by the centralWidget Layout. Now it works fine.

    Horizontal spacers work to, but if you rescale the Window the buttons are still pressed against the side.

Log in to reply