When you call ensureVisible(10000, 10000);
the scrollArea hasn't adjusted the widget's size yet. That is why it won't work.
If you create a slot that calls ensureVisible
and use QTimer::singleShot
to call that slot with the timeout set to 0 (you can also use QMetaObject::invokeMethod
with queued connection), it will work, even if you set the scroll area's widget before you set the pixmap on the label.
What also works is, if you call ensureVisible
after you call show
. But this only works if your scrollArea
is a top level window. If you embed it to a widget, it will not work.