Uploaded image for project: 'Qt for MCUs'
  1. Qt for MCUs
  2. QTMCU-168

Cannot create a QML mock for the C++ ListModel to use LivePreview and get the app launch on QDS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • Qt for MCUs 2.4
    • None
    • All

    Description

      Using Qt Creator(QC) and Qt Design Studio(QDS) iteratively is one of the things that the users would naturally expect.
       
      The thing prevents us from doing so is that the QDS cannot get the app with C++ module launched. No launching and LivePreview as a consequence.
       
      I've been trying to get this use case work by myself by making a QML mock of QML-C++ module.
      Then I realized that it may be impossible to create a QML mock for the C++ module which is representing ListModel. (Which is typically the case I assume, due to the limitation Qt for MCUs' ListModel has)
       
      Let's say there's a QML file which has ListView inside and using a ListModel which is made out of C++.

      // some_qml.qml
      Item {
          MyListModel {
          // this is made out of C++
          id: mylistmodel
        }
          ListView {
          model: mylistmodel
          // some code here
        }
      } 

      What we need to do to get this app working on QDS is to create a ListModel mock which is purely made out of QML and use it. To do so, we want to use a selector to pick the mock version of the ListModel so that we don't need to modify the qml file which uses the ListModel, in this case, "some_qml.qml."

      *Selector approach is discussed here
       
      Now, the problem is, Qt for MCUs seems not to allow ListModel QML type to be the root type, like so:

      // (ideal) Mock.qml
      ListModel {
          id: fruitModel
      
          ListElement {
              name: "Apple"
              cost: "2.45"
          }
          ListElement {
              name: "Orange"
              cost: "3.25"
          }
          ListElement {
              name: "Banana"
              cost: "1.95"
          }
      } 

      When qml is written this way, we get the error like this.

      // error
      C:/Users/81808/work/Study/Qt/QC_Sandbox/untitled2/MyList.qml:8:9: error: Binding on property of unknown type
              cost: "2.45"
              ^~~~
      C:/Users/81808/work/Study/Qt/QC_Sandbox/untitled2/MyList.qml:7:9: error: Binding on property of unknown type
              name: "Apple"
              ^~~~
      C:/Users/81808/work/Study/Qt/QC_Sandbox/untitled2/MyList.qml:6:5: error: Cannot assign to non-existent default property
          ListElement {
          ^~~~~~~~~~~
      C:/Users/81808/work/Study/Qt/QC_Sandbox/untitled2/MyList.qml:12:9: error: Binding on property of unknown type
              cost: "3.25"
              ^~~~
      C:/Users/81808/work/Study/Qt/QC_Sandbox/untitled2/MyList.qml:11:9: error: Binding on property of unknown type
              name: "Orange"
              ^~~~
      C:/Users/81808/work/Study/Qt/QC_Sandbox/untitled2/MyList.qml:10:5: error: Cannot assign to non-existent default property
          ListElement {
          ^~~~~~~~~~~
      C:/Users/81808/work/Study/Qt/QC_Sandbox/untitled2/MyList.qml:16:9: error: Binding on property of unknown type
              cost: "1.95"
              ^~~~
      C:/Users/81808/work/Study/Qt/QC_Sandbox/untitled2/MyList.qml:15:9: error: Binding on property of unknown type
              name: "Banana"
              ^~~~
      C:/Users/81808/work/Study/Qt/QC_Sandbox/untitled2/MyList.qml:14:5: error: Cannot assign to non-existent default property
          ListElement { 

      Because of this, once the project gets integrated with C++ ListModel, users can no longer use Live Preview and get the app launch in the QDS, without modify every single file which uses ListModel.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            mikio_hirai Mikio Hirai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes