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

[Solved] Are pre-processor directives supported in .qml files?



  • Hi,

    As the title suggests, I am interested in knowing if there is any support for pre-processor directives in qml files. I am mainly interested in learning if there is a way to use the #ifdefined (or something similar) around qml and embedded JavaScript code. If there is a way, can you please let me know.

    Thanks,



  • Forgot to mention that I am using Qt Creator 2.8.1 (based on Qt 5.1.1) for running my qml project under Windows 7.


  • Moderators

    Hi,

    QML and JavaScript are not compiled. Instead, they are interpreted (processed) during run-time, so there's no such thing as preprocessor directives. If you want decision-making, just use normal if/else.



  • Thanks JKSH for you answering my question. What you said makes perfect sense.


Log in to reply