user16435643
user16435643

Reputation: 3

How to prevent button from expanding in QFormLayout

I have created a subclass of QDialog in PyQt5 and then set a QFormLayout as its layout. Each row of the layout is defined similar to the following (simplified): layout.addRow(QLineEdit(), QPushButton('Push Me'))

I have set the dialog to fixed height, but if I stretch the dialog horizontally, the button gets wider and the line edit stays the same width. What I want is for the line edit to get wider and the button size to remain unchanged. I have tried setting size policy for the button, but apparently QFormLayout ignores this. I have also tried making each row of the form layout a QHBoxLayout which contains the line edit and button; this did not work either. Does anyone have a solution to this problem? I really need for the button to remain on the right had side of the form.

Upvotes: 0

Views: 296

Answers (0)

Related Questions