Best practice for non UI multiplatform issues
I wonder what would be the best strategy to deal with some platform dependent issues for QML. Specifically, I have two issues as below.
- Use different file path depending on platforms
I have some media files for my QML app on local file system, but file path is different depending on platform. For example, /home/user/MyDocs/... on N900, /home/xyz/data/... on Linux, C:/Documents and Settings/xyz/data/... on Windows. Is there any QML global variable to identify platform so that I can use proper path on the fly? For now, I manually change path in the code each time changing platform to test, which is really cumbersome.
- Use QML plugin for different platforms
I have my own QML plugin placed in the sub-folder of QML files, as well as 'qmldir' file. For now, in order to test on different platforms, I have to manually modify qmldir to point the right plugin file, which is, again, really cumbersome. My qmldir looks like this;
plugin myplugin pluginx86 # use this when running on x86 Linux
plugin myplugin pluginarm # use this when running on N900
There is no QML global variable that identifies the current platform. You could integrate with some C++ code that checks for the Q_OS_MAC Qt define if necessary. However there may be alternative options; for example, if you are looking for the platform-specific documents path, you could use QDesktopServices::storageLocation() with QDesktopServices::DocumentsLocation.
In regards to installing different plugins on different platforms, I'm not sure if this can be done. Perhaps you could write the platform-specific behaviour into the one plugin instead.
Thanks for the tips! Sounds like use of C++ Qt is the way to go.