Environment variables inside the main fuction

  • I was watching this video: QtWS15- Effective QML, and speaker (Thomas) said that you cannot set environment variables inside the main function.

    But I have them there and they do work:

    int main(int argc, char *argv[])
        // here's the environment variable
        qputenv("QSG_VISUALIZE", "overdraw");
        QGuiApplication app(argc, argv);
        QQmlApplicationEngine engine;
        return app.exec();

    Has something changed for the last year? Or I don't understand something?

  • Hi, I think he's referring to when you have statically declared class instances, the constructors for them are run before your main() starts.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.