[Qt-creator] Determine if started through Qt Creator

Walter Stefan Stefan.Walter at lisec.com
Sun Mar 6 11:19:14 CET 2016


Thanks, but is there not a more generic way. I don't want to set this in every single project.

Regards,
Stefan

-----Original Message-----
From: Qt-creator [mailto:qt-creator-bounces+stefan.walter=lisec.com at qt-project.org] On Behalf Of Nikos Chantziaras
Sent: Sonntag, 6. März 2016 14:06
To: qt-creator at qt-project.org
Subject: Re: [Qt-creator] Determine if started through Qt Creator

On 06/03/16 08:47, Walter Stefan wrote:
> Hi,
>
> I would like to determine in my application, if it was started through 
> Qt Creator.
>
> My code should behave slightly different between running from 
> Qt-Creator (error handling) or started directly from a terminal.
>
> What is the best approach for this?

In the project settings, you can modify the environment. Choose the "run" configuration, and just add an environment variable. Name it whatever you want, like IN_QTCREATOR.

In your program, just use:

   qEnvironmentVariableIsSet("IN_QTCREATOR");

(http://doc.qt.io/qt-5/qtglobal.html#qEnvironmentVariableIsSet)

to detect if the variable is set. Obviously, it only going to be set if you run the program in Creator.


_______________________________________________
Qt-creator mailing list
Qt-creator at qt-project.org
http://lists.qt-project.org/mailman/listinfo/qt-creator




More information about the Qt-creator mailing list