@Inzinejkr said in How to use QStackedWidget:
I can't wrap my head around this sentence
Oh dear, I try to make my answers clear, sorry about that!
If you do not go setCurrentIndex(something) then the widget being shown is just whatever it was however you left it in the Designer. Which might be some blank widget if that's what you had there, or possibly "nothing" if QStackedWidget allows that.
Either way, what you have now done sets the current widget explicitly from code, so it will indeed be one of the widgets you added into the stack in your code at runtime. Hence fixing your issue.
With a QStackedWidget it is your task in code to call setCurrentIndex() whenever you want the current widget displayed to change. A QTabWidget behaves like a QStackedWidget, but has the additional "furniture" of a QTabBar to provide an interface to the user for changing which page/widget is shown.