Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Environment variables inside the main fuction
QtWS25 Last Chance

Environment variables inside the main fuction

Scheduled Pinned Locked Moved Unsolved General and Desktop
environment var
2 Posts 2 Posters 870 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    veryqtperson
    wrote on 29 Aug 2016, 10:01 last edited by
    #1

    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");
    
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        engine.load(QUrl(QLatin1String("qrc:/main.qml")));
    
        return app.exec();
    }
    

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

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hskoglund
      wrote on 29 Aug 2016, 11:01 last edited by
      #2

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

      1 Reply Last reply
      2

      2/2

      29 Aug 2016, 11:01

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved