Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Does QT have any way of "knowing" which plataform is being used?



  • Hi, I'm doing a project that works on both desktop and mobile, the problem is... How can I tell QT that the project is running on desktop or mobile? The screen design is different between desktop and mobile, and, as we know, the size / resolution between a pc and a mobile phone can be very different, making automatic resizing very difficult. So is there any way for QT to know when it's mobile or desktop?


  • Lifetime Qt Champion

    Hi
    Since the exe of a Desktop will be different than the exe for a phone then normally one uses
    #ifdef Q_OS_ANDROID
    ...code..
    #endif

    Q_OS_LINUX
    Q_OS_WIN64
    Q_OS_IOS

    etc to have platform dependant code so it's only compiled in when app is compiled for that platform.

    full list here
    https://doc.qt.io/qt-5/qtglobal.html


Log in to reply