[SOLVED] - Detecting OS - runtime vs build



  • Hi guys,

    I'm currently developing a software that is available for Mac, Windows and Linux and maybe IOS later.
    I want to pop up a link when the user start my application, the link will be different if the OS is Mac/Win/Linux.

    Is it better to do this kind of coding at build time with
    @ #ifdef WIN32
    OS = "WIN";
    #else
    OS = "MAC";
    ....@

    Or at runtime with QSysInfo ?
    Thanks in advance!



  • Solved with this added in Main.cpp:

    @ QString OS;
    #ifdef Q_OS_WIN32
    OS = "WIN";
    #elif Q_OS_MAC
    OS = "MAC";
    #else
    OS = "LINUX";
    #endif
    qDebug () << "OS IS: " << OS;
    app.setProperty("OS", QVariant(OS));@


Log in to reply
 

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