Search code examples
qtqt4symbianwidgetnokia

How to delete a widget from a stacked widget in Qt


Using QStackedWidget to switch between the views, I will be able to traverse between the views.

I am facing problem in some scenarios, where I do not require the widgets, but I want to remove them completely.

QStackedWidget provides the functionality to remove widgets, still the ownership of the widget will be there, I mean widget will be hidden.

I don't want this to be happen - when I call remove widget it should be deleted. How should I handle this?


Solution

  • Have you tried simply deleting the object after removing it? i.e.

    stackWidget->removeWidget(myWidget);
    delete myWidget;