how to best set OS specific properties in plugin

• Sep 10, 2019 - 20:58

Hello.

I need some properties to adapt to the OS, namely file paths and executable location. For now they are commented in the script, up to the user to uncomment the ones s.he needs... but that's not nice for non developpers.

The compile-time macro #ifndef Q_OS_WIN don't seem to work.

What are other (better) options to make some part of the QML code OS-aware ? (mostly distinguishing Linux; from Windows; from MacOSX)

Thanks.
Berteh.


Comments

In reply to by berteh

I ended up using syntactic sugars. Works... but not great if you need to test for multiple platforms or have many properties... so better options are still welcome.

property string mmaPath : Qt.platform.os == "windows" ?winMMAPath:nixMMAPath;
property string midPath : Qt.platform.os == "windows" ?winMIDPath:nixMIDPath;
property string mmaCommand : Qt.platform.os == "windows" ?"cmd.exe /c "+winMMACommand:nixMMACommand;

Do you still have an unanswered question? Please log in first to post your question.