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

Enable exposing readonly properties from C++

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt fo MCUs 2.5.2
    • QUL Team

    Description

      Let's assume that in code snippet below Flickable.visibleArea.xPosition should be readonly:

      pragma main;
      
      Image {
          id: root
      
          Flickable {
              id: flickable
          }
      
          Timer {
              interval: 200
              running: true
              onTriggered: flickable.visibleArea.xPosition = 5;
          }
      }
      

      In regular Qt / QML we get a following kind of error at runtime (which in case of Qt for MCUs should be a suitable compile error):

      ...ListView.qml:35: TypeError: Cannot assign to read-only property "xPosition"

      Current workaround for exposing readonly proprties from C++ (for example in case of temperature measurement) is to implement a signal handler tempMeter.setPointer(temperature) which arguably is not very QMLish thing to do.

      As suggestion:
      It should be possible to specify properties as "readonly" from C++ maybe by having Qul::Property<int, Qul::ReadOnly> property extension or by implementing Qul::ReadOnlyProperty<T>.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            foxxx Tuukka Kettunen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes