Since the window should be cleared, drawn and displayed completely each time, to stop showing something, you simply stop drawing it. If you want to draw something different, draw that instead.
The concept of switching between "screens" or "states" can be found by googling something like "state machine" or "screen state".
I believe eXpl0it3r has a basic version somewhere from that you can learn.
If a state manager is a little daunting at first, consider starting of using an alternative using flags with ifs or enums with switches. The code can get a bit messy (or at least rather indented) but it's a good starting point to see what's going on.
Here's an example (it's not complete; you'll need to create the window, include stuff and put it in main(), for example):
sf::Rectangle rectangle({ 200.f, 100.f });
sf::CircleShape circle(100.f);
sf::CircleShape triangle(100.f, 3u);
enum class Screen
{
One,
Two,
Three
} screen{ Screen::One };
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
else if (event.type) == sf::Event::Keypressed)
{
if (event.key.code == sf::Keyboard::Num1)
screen = Screen::One;
else if (event.key.code == sf::Keyboard::Num2)
screen = Screen::Two;
else if (event.key.code == sf::Keyboard::Num3)
screen = Screen::Three;
}
}
window.clear();
// this is the important part of this example
switch (screen)
{
case Screen::One:
window.draw(rectangle);
break;
case Screen::Two:
window.draw(circle);
break;
case Screen::Three:
window.draw(triangle);
break;
}
window.display();
}
In this example, you can change "screens" by simply pressing the 1, 2 or 3 keys. Each screen has on it a different shape.