Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-16547

Javascript constants not allowed in models

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.0.0
    • 4.7.1
    • None
    • Qt 4.7.1, QtCreator 2.0.1, 2.1 RC.
    • 8fda8d16df9744b69a97020e3aae1ad40ff1f538

    Description

      I tried to create a numeric keyboard and stuck at the following: I want to let every button handle its own key, so I pass this key through the model:

      Model
      Repeater {
        model: ListModel {
          id: model
          ListElement { label: "7"; value: "7"; key: Qt.Key_7 }
          ...

      In the button component (delegate) I use this:

      Delegate
      Keys.onPressed: {
        if (event.key == model.key) {
          event.accepted = true;
          clicked(model.value);
          ...

      But the point is that it doesn't let me use Qt.Key* constants:

      file:///D:/Projects/qmlinterface/Controls/Numpad.qml:25:43: ListElement: cannot use script for property value 
      ListElement { label: "7"; value: "7"; key: Qt.Key_7 }
                                            ^

      There are workarounds (scancode hardcoding, string-scancode hash function, etc) but all that is workarounds with overhead, complications, performance flaws.
      Please implement using script constants in models.

      Attachments

        1. Numpad.qml
          3 kB
          katroevsky
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            brasser Michael Brasser (closed Nokia identity) (Inactive)
            leonty leonty
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes