QDesigner form automatic resizing
I'm affraid the question has been asked before but I couldn't find a satisfying answer neither on the documentation nor in the FAQ's and forum.
The question is: I want to create a QWidget (or QDialog) with QDesigner. It will simply contain a QTableWidget and a "Close" QPushButton. But I want the TableWidget to resize when the QWidget is resized, but not the PushButton. Seems easy... Any help is appreciated.
If we are talking vertical resizing, the button will not change size anyway; its default vertical size policy is
QSizePolicy::Fixed. If we are talking horizontal, then again, the button's default horizontal size policy is
QSizePolicy::Minimum, so it'll occupy the minimum amount of space when put side to side with an expanding widget (such as
So the answer seems to be:
Add both your widgets to a layout and you should be good to go.
Hi, thanks for aswering. I tried to add a vertical layout, put the QTableWidget on the top and the button on the bottom, but when I resize the window, the TableWidget keeps its original size, it does seem to adapt to the new size. I certainly missed something to do to instruct the layout to resize with the parent widget.
@jcga Hi! Please post a drawing of what your form shall look like. I'm sure we can find a solution quickly.
Edit: To post an image, upload it to, e.g., https://postimage.org, and then embed it here with
![alternate text](image url)