The layout is the only thing that actually sizes the widgets. The layout does that by combining the constraints it has (i.e. the client area of the widget it is attached to) with the demands and suggestions of the widgets that have been added to the layout. The child widgets have a size policy and size hint that express preferences about the sizing of the widget that the layout can use.

In the case of a default button the size policy is Preferred in the horizontal direction and Fixed in the vertical direction. The size hint is driven by the button size needed for the label. In the vertical direction the layout has not resized the buttons to fill the available space precisely because of their size policy. The button horizontal size policy allows for any size, and the layout has stretched them to fit the space available in that direction. The split of space is equal because the two buttons were added to the layout with equal (default) stretch factors.

If you specify alignment of one of the buttons then you are directing the layout to place the widget within the space available to it rather than sizing it to fit. The widget in that case assumes its sizeHint() and is placed, top/bottom left/right etc. of the available space as directed. The space available to each widget does not change with alignment. See the example code and result below (Button 1 and 3 are the same size regardless of the alignment of Button 4)

Qt Code:
  1. #include <QApplication>
  2. #include <QWidget>
  3. #include <QPushButton>
  4. #include <QHBoxLayout>
  5. #include <QVBoxLayout>
  6.  
  7. int main(int argc, char **argv) {
  8. QApplication app(argc, argv);
  9.  
  10.  
  11. // Default
  12. QHBoxLayout *layout1= new QHBoxLayout();
  13. layout1->addWidget(new QPushButton("Button 1"));
  14. layout1->addWidget(new QPushButton("Button 2"));
  15.  
  16.  
  17. // Alignment used
  18. QHBoxLayout *layout2= new QHBoxLayout();
  19. layout2->addWidget(new QPushButton("Button 3"));
  20. layout2->addWidget(new QPushButton("Button 4"), 0, Qt::AlignHCenter);
  21.  
  22. QVBoxLayout *layout= new QVBoxLayout(&w);
  23. layout->addLayout(layout1);
  24. layout->addLayout(layout2);
  25.  
  26. w.show();
  27. w.resize(800, 150);
  28.  
  29. return app.exec();
  30. }
To copy to clipboard, switch view to plain text mode 
Screenshot_20210411_122444.jpg

Your images show a change in size of the left button: without your code I cannot tell you why that is.