How to set a layout in the center of a Widget?
-
-
you can use the horizontal spacers to do this. When the window is resized it will keep the button in the middle.
Greetz
-
You don't position layouts, they fill their parent widgets. You can either use spacers, or simply calculate the center of your parent widget and move your child widget there manually.
You have a geometry() function which returns the QRect of the parent widget, for QRect you have a center() function, which returns a QPoint which is the very center of the rectangle, which you can use for the child widget's move(QPoint&) function to move it to those coordinates.
@// move child widget to its parent's geometry center
yourWidget.move(yourWidget.parentWidget()->geometry().center());
@note - parentWidget() is a function that returns a pointer to the parent widget, not the actual name of the parent widget