Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Best practice for non UI multiplatform issues
Forum Updated to NodeBB v4.3 + New Features

Best practice for non UI multiplatform issues

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    moo1
    wrote on last edited by
    #1

    I wonder what would be the best strategy to deal with some platform dependent issues for QML. Specifically, I have two issues as below.

    1. 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.

    1. 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

    1 Reply Last reply
    0
    • B Offline
      B Offline
      blam
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        moo1
        wrote on last edited by
        #3

        Thanks for the tips! Sounds like use of C++ Qt is the way to go.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved