Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-18820

Clarify on how JS signal handlers should be handled for .ui.qml files

    XMLWordPrintable

Details

    Description

      The wizard for Qt Quick propose a certain style on how purely declarative .qml.ui files can be used in components and augmented by logic. e.g. the Qt Quick Controls 2 wizard produces a Page1.qml file

      import QtQuick 2.7
      
      Page1Form {
          button1.onClicked: {
              console.log("Button Pressed. Entered text: " + textField1.text);
          }
      }
      

      Anyhow, following the example to implement textField1.onEditingFinished fails:

      
          textField1.onEditingFinished: {
              console.log(textField1.text)
          }
      
      // ...
      qrc:/main.qml:17 Type Page1 unavailable
      qrc:/Page1.qml:9 ".onEditingFinished" is not available due to component versioning.
      

      Apparently one has to use a much more verbose syntax then:

          Connections {
              target: textField1
              onEditingFinished: {
                  console.log(textField1.text)
              }
          }
      

      It is unclear to me when the simple slot works, and when one has to use a Connections element.

      Attachments

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

        Activity

          People

            thohartm Thomas Hartmann
            kkohne Kai Köhne
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes