Could you consider putting the group boxes into a QStackedWidget? QStackedWidget would take the size hint of both group boxes into consideration.