The code below works fine for me. Please make sure that the clear command works fine in your console first.
main.cpp
#include <QProcess>
#include <QDebug>
int main()
{
QProcess::execute("clear");
qDebug() << QProcessEnvironment::systemEnvironment().contains("TERM");
return 0;
}
main.pro
TEMPLATE = app
TARGET = main
QT = core
SOURCES += main.cpp
Build and Run
qmake && make && ./main
Note that if you are using QtCreator, you will need add the environment variable with its value explicitly in the build settings tab. Here you can find more details in the documentation: