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. Portable QML app using Qt Component
Qt 6.11 is out! See what's new in the release blog

Portable QML app using Qt Component

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.3k 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.
  • L Offline
    L Offline
    luca
    wrote on last edited by
    #1

    Hi all,
    I'd like to use Qt Component in a QML application that I also use in a Linux Desktop.

    The main.qml for Desktop start with:
    @
    import QtQuick 1.1
    Item
    {
    id: window
    signal effettuaLogin(string nome, string password)

    Rectangle {
        id: root
    

    ...
    ...

    @

    while the same main file for N9 should start with:
    @
    import QtQuick 1.1

    import com.nokia.meego 1.1

    PageStackWindow {
    id: window

    signal effettuaLogin(string nome, string password)
    
    Rectangle {
        id: root
    

    ...
    ...
    @

    The problem is that the N9 version doesn't compile for Linux Desktop. This way I must keep two different main file for different platform.

    Is there a way to use the same main for both platform?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chriadam
      wrote on last edited by
      #2

      Not really. You can use a bootstrap main.qml which basically reads a context object property (eg, "isDesktop" or something) which you set in your C++ entrypoint, and based on that value, dynamically loads either one or the other file.

      eg, something like:

      @
      // platform-independent main qml, which loads platform-specific main qml.
      import QtQuick 1.1

      Item {
      Loader {
      id: loader
      }

      Component.onCompleted: {
          if (contextObject.isDesktop) {
              loader.setSource("desktopmain.qml");
          } else {
              loader.setSource("n9main.qml");
          }
      }
      

      }
      @

      1 Reply Last reply
      0
      • L Offline
        L Offline
        luca
        wrote on last edited by
        #3

        Thanks, I'm trying that...

        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