QT-如何读取windows系统环境变量

相关资料:

https://blog.csdn.net/sunboyhch/article/details/8846039

 

// 方法一:
void MainWindow::on_pushButton_clicked()
{
    QString path = QProcessEnvironment::systemEnvironment().value("PATH");
    qDebug() << path;
}
// 方法二:
void MainWindow::on_pushButton_2_clicked()
{
    QStringList environment = QProcess::systemEnvironment();
    QString str; foreach(str,environment)
    {
        qDebug()<<str;
         if (str.startsWith("PATH=", Qt::CaseInsensitive))
         {
             ui->textEdit->append(str);
             break;
         }
     }
}

 

voidMainWindow::on_pushButton_clicked()
{
QStringpath=QProcessEnvironment::systemEnvironment().value("PATH");
qDebug()<<path;
}

voidMainWindow::on_pushButton_2_clicked()
{
QStringListenvironment=QProcess::systemEnvironment();
QStringstr;foreach(str,environment)
{
qDebug()<<str;
if(str.startsWith("PATH=",Qt::CaseInsensitive))
{
ui->textEdit->append(str);
break;
}
}
}

posted on 2020-06-17 09:41  疯狂delphi  阅读(1061)  评论(0编辑  收藏  举报

导航