I'm replying to my post.
Indeed this happens because the scroll area's widget changes it geometry with every button that is added. Thus, ensureWidgetVisible cannot be called immediately because the scroll area does not know its final size yet. A way around is to subclass a QWidget and emit a signal after the widget size changes (by reimplementing the resizeEvent) + setting this widget as the scroll areas's widget. After connecting the signal, ensureWidgetVisible can properly scroll to the added widget.
Bookmarks