RPATH is great. But remember, when the library is installed in a path included in LD_LIBRARY_PATH, the installed library takes priority over the one pointed by RPATH.
Next time that QTest executables run directly or through Valgrind don’t change their behavior after modifying the library code, but when executed through shell files they do, that’s what is going on.
Yes, pretty obvious. But I’m sure that it is not the first time that you get stuck for an hour in something like that
(and that then, after realizing what’s happening, you feel like a moron
).