Recently I had a requirement to install a shared library as a build/deployment step in a QtCreator project, which of course required sudo permissions. Not surprisingly Qt Creator does not simply let you prepend “sudo” to a custom build step, here is the workaround I found:
First I moved all the commands that needed to run with sudo into a single make file like the following, mine was called InstallLib.make:
Next in Qt Creator with your project open, goto the project section, add a new “custom process” build step. In the command field type: “ssh-askpass” this program will popup a widget to enter the sudo password when executed. In the build step arguments field enter: “Sudo Password | sudo -S make -f InstallLib.make”. This will make the ssh-askpass program execute the “InstalledLib.make” make file when a correct sudo password is provided.
If you prefer not to use the GUI, you could also edit your projects .user file and add some xml similar to the following: