I have to develop C++ programs that have to run on Scientific Linux 5 or 6. I would like to develop with QtCreator on Ubuntu which has much more recent libraries than the one fo
Not sure it is lightweight enough for what you need (I'm not very familiar with virtualenv) but you can try the CDE Project which is a very nice way of creating a virtual sandbox with all kinds of dependencies.
You can establish the dependencies and the compiler for a given project using a build system like bazel (https://bazel.build/) or please (https://please.build/).
It will never be the same exact as a virtualenv, due to the different nature of the language, and since it will still be using the system compiler. In case you want to have your project completely isolated, you can ship the project on a docker container.
Use debootstrap to create the chroot environment (or even install ubuntu on a separate partition). Mount your home dir with mount -o bind. Use schroot convenient chroot setup.
http://manpages.ubuntu.com/manpages/precise/en/man8/debootstrap.8.html
http://manpages.ubuntu.com/manpages/precise/en/man8/mount.8.html
http://manpages.ubuntu.com/manpages/precise/en/man1/schroot.1.html
You can use tools below: