How to delete all widgets from QStackedWidget? I need simply remove all widgets from QStackedWidget.
How to delete all widgets from QStackedWidget?
6.1k Views Asked by htzfun At
2
There are 2 best solutions below
0
On
I tried this example in Python As a result of 5 pages, only 3 were deleted.
I did some checks and as result come up with an understanding, in a loop page with index 0 needs to be deleted all the time, because then you delete page 0, page 1 becomes 0
pages = self.ui.stackedWidget_2.count()
for i in range(pages):
widget = self.ui.stackedWidget_2.widget(0);
self.ui.stackedWidget_2.removeWidget(widget);
You need to iterate through all widgets and remove each of them: