Important: Please read the Qt Code of Conduct -

Memory vs effiency of QStackedWidget

  • I noticed that when creating a multi page application with a stacked widget all "pages" are initialized, thus loaded into memory. How does this affect the overall memory usage?
    Is a setup us where upon a signal, like a button click, a series of widgets are destroyed and a new series are created/initialized to create a new page efficient?
    Any sources for discussion on this topic would be appreciated as well.
    Thank you,

  • Lifetime Qt Champion


    This will depend on your widgets and what their content. It will also depend on the device that runs your application. But more seriously, unless you are under very high memory constraints you should allocate the widgets commonly used from the start and the ones that are less often used when they are needed.