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. Deployment of different QML files
Forum Updated to NodeBB v4.3 + New Features

Deployment of different QML files

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 1.1k Views 2 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.
  • E Offline
    E Offline
    eswar
    wrote on last edited by A Former User
    #1

    I have two QML files of same project. The UI apperance of two files are different based on mobile and desktop machine. If i select the desktop deployment, the one QML file will be deployed. If I choose Android deployment, the another file will be loaded in the loader. How i can choose QML file based on the deployment of target platform?

    L 1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @eswar You can make use of the platform object.
      Check this.

      157

      1 Reply Last reply
      0
      • E eswar

        I have two QML files of same project. The UI apperance of two files are different based on mobile and desktop machine. If i select the desktop deployment, the one QML file will be deployed. If I choose Android deployment, the another file will be loaded in the loader. How i can choose QML file based on the deployment of target platform?

        L Offline
        L Offline
        literA2
        wrote on last edited by literA2
        #3

        @eswar you can also use QQmlFileSelector

        1 Reply Last reply
        1
        • E Offline
          E Offline
          eswar
          wrote on last edited by
          #4

          @p3c0 @literA2

          Thanks for your reply

          I go through the QQmlfileselector. But i can't understand, how to implement in main file. Please provide the links or example related to this topic.

          L 1 Reply Last reply
          0
          • E eswar

            @p3c0 @literA2

            Thanks for your reply

            I go through the QQmlfileselector. But i can't understand, how to implement in main file. Please provide the links or example related to this topic.

            L Offline
            L Offline
            literA2
            wrote on last edited by
            #5

            hi @eswar

            To implement it in your main.cpp file, you just need to create a new instance of QQmlFileSelector.

            new QQmlFileSelector(QQmlEngine);
            

            Then, your data directory should be like this:

            qml/+android/File.qml   //this file will be called if you are compiling in Android
            qml/File.qml            //this is your base file which will be used when in Desktop
            

            In your qml files, you just have to call File{}, qml will automatically call the correct file to instantiate.
            Please be reminded that both files should have the same properties, even if it is not being used by the other.

            hope this will help.

            1 Reply Last reply
            1

            • Login

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