首页 > 系统服务 > 详细

QT获取linux下的当年用户名

时间:2019-12-05 15:17:33      阅读:72      评论:0      收藏:0      [点我收藏+]

故事背景:客户端启动的时候需要加载机器/home/xx/test.jpg的图片作为背景图,但是有的机器用户名叫AAA,有的机器名叫BBB,所以我需要获取当前用户的home目录

技术调研:QStandardPaths

    QString strImagePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/justtake.jpg";
    QFile file(strImagePath);
    if(file.exists())
    {
        this->setStyleSheet(QString("#firstWidget{border-image:url(%1)}").arg(strImagePath));
    }else
    {
        this->setStyleSheet("background-color:white");
    }

 

大家可以根据自己的业务需求进行扩展,评论区随时交流。

QT获取linux下的当年用户名

原文:https://www.cnblogs.com/xupeidong/p/11989455.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!