This happen because you remove the viewport instead the button in your example code.
when you call
main_area.add(button_test);
you add a Gtk::Viewport to the scrolled window, the button is then a child of the viewport.
So after the call to
main_area.remove();
you remove the viewport and the button is still a child of the viewport.
This happen because you remove the viewport instead the button in your example code. add(button_ test);
when you call
main_area.
you add a Gtk::Viewport to the scrolled window, the button is then a child of the viewport.
So after the call to
main_area.remove();
you remove the viewport and the button is still a child of the viewport.