Solved 'qEnvironmentVariable' was not declared in this scope
-
QString sysuser = qEnvironmentVariable("USER");
works on Opensuse
but i cannot build the same code on neither Ubuntu nor WinI tried including QtGlobal but did not help
-
@Seb-Tur Which Qt version?
Please show the code. -
@Seb-Tur said in 'qEnvironmentVariable' was not declared in this scope:
QString sysuser = qEnvironmentVariable("USER");
on Opensuse where it works qt 5.15
on Ubuntu fails on qt 5.9.5
on win fails on qt 5.5code is very simple
void MainWindow::on_pushButton_clicked() { QString sysuser = qEnvironmentVariable("USER"); if (sysuser.isEmpty()) sysuser = qEnvironmentVariable("USERNAME"); ui->pole->setText(sysuser); }
-
Hi,
As stated in the documentation of qEnvironmentVariable it was added in Qt 5.10.
-
Solution : use qgetenv()
-
@Seb-Tur This fixed my error, thanks!