ulak blade
ulak blade

Reputation: 2665

Qt resizing child widgets with the parent

I have made a custom widget in the UI designer which consists of the main window(which I resized to 700 width and 30 height) and inside it I have a QLineEdit that is 30 height and 770 width and next to it a [X] button that is 30 width and 30 height. I want to make it such that when the main window behind them is resized, the QLineEdit is resized too(horizontally), but the button always remains next to it. The problem is that right now when I resize the thing, the button gets obscured away.

Upvotes: 3

Views: 12541

Answers (1)

x squared
x squared

Reputation: 3354

try to add a QHBoxLayout to your custom widget first and then add the QLineEdit and the QPushButton into the layout.

Layouts ensure that widgets stay properly ordered and resize correctly with the main widget.

It is also worth reading section "Adding Widgets to a Layout" in the Layout Management documentation

Upvotes: 3

Related Questions