amin-ahmadi.com
How to Get Current User Name in Qt/C++ (for Linux) - Amin
You can use the following function to get current user name is Linux. I have tested this on Ubuntu and CentOS flavors but it should also work with other flavors without any issues. Basically it uses whoami program to query the current user name and read the outputs of the process:
Amin