I designed a QMainWindow
with QtCreator's
designer. It consists of the default central widget (a QWidget
) which contains a QVBoxLayout
with all the other widgets in it. Now everything I want, is that the QVBoxLayout
automatically occupies the whole central widgets rectangle space.
How can I do this? I didn't find any usable property neither in the central widgets properties nor the QVBoxLayout's
ones.
You don't have to create a
QVBoxLayout
manually. Just select your centralQWidget
and press a make-layout button.If you want to do it with code instead of using
QtCreator
, you could set the layout in aQWidget
and then set theQWidget
as the central widget of the main window like this:Add at least one widget on your
MainWindow
. Then select your window by clicking on it and click on theVerticalLayout
Button at the top ofQTCreator
. You Vertical Layout is automatically added to the central widget and fills all the surface.This is already answered, but I personally prefer to keep all control elements and layouts added manually to the form. I do not add controls in the class files, I merely hook up the signals/slots to hide/show widgets relevant to the logic in the class, within the class.
To manually add a layout to any widget you must first add at least one child widget/control. That wasn't totally clear to me and I was trying to add the layout first.