Place the widget in the center of QScrollArea

How to place a custom fixed size widget in the center of QScrollArea?

I can place the widget manually inside QScrollArea using myWidget.pos (x, y), but there is no variable size signal in QScrollArea, so this position will be incorrect if the scroll area has changed.

+3
source share
1 answer

I used the @thuga suggestion to set the alignment, but additionally I had to set a fixed size for the widget (I used to have only the minimum size settings), and I also needed to use the horizontal layout instead of the vertical one. For some reason, the vertical layout ignores the horizontal alignment of the scroll area.

I used setFixedSize()to set a fixed size for my custom widget, but layout and alignment can be set from Qt Designer.

0
source

All Articles