qt4
qt5
QString USBMainUI::getUserName()
{
QString userName = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
userName = userName.section("/", -1, -1);
return userName;
}
qt5
#include <QStandardPaths>
QString getUserName()
{
QString userPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
QString userName = userPath.section("/", -1, -1);
return userName;
}