How to make a Qt Widget grow with the window size?

后端 未结 4 1968
灰色年华
灰色年华 2020-11-29 18:38

I want to have a small QFormLayout that grows to fill its parent widget.

I created a new .ui file using the QWidget template in Qt

4条回答
  •  爱一瞬间的悲伤
    2020-11-29 18:54

    The accepted answer (its image) is wrong, at least now in QT5. Instead you should assign a layout to the root object/widget (pointing to the aforementioned image, it should be the MainWindow instead of centralWidget). Also note that you must have at least one QObject created beneath it for this to work. Do this and your ui will become responsive to window resizing.

提交回复
热议问题