Important: Please read the Qt Code of Conduct -

Can't get QPushButton to center vertically in a QGridLayout cell

  • I have a QPushButton I am trying to get to center vertically next to a text field and for the life of me, I can't figure out how to do it!

    Here's a image showing the problem:

    I don't understand how other items "get it" like labels and textfields and spinner fields. But then comes along a QPushButton and it has to be different!

    I have tried this with the buttons style sheet, with no success obviously:

    @QPushButton {border-width: 0px; padding: 0px}@

  • How have you tried to do it?

    If you used Designer then right-click on each push button and select "Center Vertically" from the Layout Alignment menu. If you used code then you do the equivalent with QLayout::setAlignment().

Log in to reply