linux系统 Qt获取用户名

来源:互联网 发布:worktile for mac 编辑:程序博客网 时间:2024/06/01 18:43
qt4
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;}


0 0
原创粉丝点击