Important: Please read the Qt Code of Conduct -

[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";
    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";
    OS = "LINUX";
    qDebug () << "OS IS: " << OS;
    app.setProperty("OS", QVariant(OS));@

Log in to reply