title: How to set an environment variable programmatically for the current process in Qt?
body: <p>I use the GDAL. CPLSetConfigOption("GDAL_DATA", "mygdaldir") works, but throws an exception when finishing the app. It is possible to set GDAL_DATA as "global" environment variable but I want to do it programmatically for the current process instead of configure it externally.</p>
  
  <p>Any ways how to set an environment variable for the current process/app itself?</p>
  
  <p>EDIT:</p>
  
  <p>Found the problem: GDAL_DATA pointed to the wrong directory => GDAL fails to unload correctly. Anyway, @Greenflow gives us a fitting answer to my question and even if I don't need his solution I accepted his answer.</p>