That is an acceptable solution and probably the most intuitive.
However, there is another that could be simpler with a little more knowledge of how the view works.
Set the view to always be the same. In this case, a simple view that goes from (0, 0) to (1, 1) would be fine.
This view then never needs to change.
Scale the sprite so that it fits into a 1x1 space.
You can simply divide 1 by its sizes.
You could also use a rectangle of 1x1 size or a vertex array but remember to get the correct texture co-ordinates.
This should do it whatever the size of window as long as the window isn't "re-created" ;D
During creation of the window:
window.setView(sf::View({ 0.f, 0.f, 1.f, 1.f }));
After loading the texture (presuming that the entire texture is being used):
sprite.setScale({ 1.f / static_cast<float>(texture.getSize().x), 1.f / static_cast<float>(texture.getSize().y) });